Skip to content

Commit 20018b6

Browse files
committed
Fix ordering when flush and multiple batches
1 parent fa3f83c commit 20018b6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/publisher/message-queues.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,12 @@ export class OrderedQueue extends MessageQueue {
303303
/**
304304
* Starts a timeout to publish any pending messages.
305305
*/
306-
beginNextPublish(): void {
306+
beginNextPublish(callback?: PublishDone): void {
307307
const maxMilliseconds = this.batchOptions.maxMilliseconds!;
308308
const timeWaiting = Date.now() - this.currentBatch.created;
309309
const delay = Math.max(0, maxMilliseconds - timeWaiting);
310310

311-
this.pending = setTimeout(() => this.publish(), delay);
311+
this.pending = setTimeout(() => this.publish(callback), delay);
312312
}
313313
/**
314314
* Creates a new {@link MessageBatch} instance.
@@ -361,7 +361,7 @@ export class OrderedQueue extends MessageQueue {
361361
this.handlePublishFailure(err);
362362
definedCallback(err);
363363
} else if (this.batches.length) {
364-
this.beginNextPublish();
364+
this.beginNextPublish(callback);
365365
} else {
366366
this.emit('drain');
367367
definedCallback(null);

0 commit comments

Comments
 (0)