Skip to content

Commit ddcfac9

Browse files
committed
Copy and empty bulkBody when flushBytes is reached
Before it was waiting until after semaphore resolved, then sending with a reference to bulkBody. If flushInterval is reached after `await semaphore()` but before `send(bulkBody)`, onFlushTimeout is "stealing" bulkBody so that there is nothing left in bulkBody for the flushBytes block to send, causing an indefinite hang for a promise that does not resolve.
1 parent 291b3af commit ddcfac9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/helpers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,11 @@ export default class Helpers {
648648

649649
if (chunkBytes >= flushBytes) {
650650
stats.bytes += chunkBytes
651-
const send = await semaphore()
652-
send(bulkBody.slice())
651+
const bulkBodyCopy = bulkBody.slice()
653652
bulkBody.length = 0
654653
chunkBytes = 0
654+
const send = await semaphore()
655+
send(bulkBodyCopy)
655656
}
656657
}
657658

0 commit comments

Comments
 (0)