fix(core): build chunks by appending so oversized events don't stall … - #1318
Open
abueide wants to merge 1 commit into
Open
fix(core): build chunks by appending so oversized events don't stall …#1318abueide wants to merge 1 commit into
abueide wants to merge 1 commit into
Conversation
…the queue `chunk()` assigned batches by index (`chunks[++currentChunk] = [item]`). When the first item alone was `>= maxKB`, `currentChunk` went 0 -> 1 and index 0 was never written, producing a sparse array. Since 2.23.0 the upload path iterates batch results with `for...of`, which does not skip holes, so `aggregateErrors` read `.status` off `undefined` and every flush threw. The throw escapes `sendEvents` after the upload but before `processUploadResults`, so nothing is ever dequeued and the queue only recovers when `pruneExpiredEvents` discards the events 12 hours later. `rollingKBSize` was also never reset when a new chunk started, so once the cumulative size crossed `maxKB` every remaining item became its own batch and the `count` limit became unreachable. Build the chunks by appending and reset the accumulator per chunk. This removes the hole, restores the `count` limit, and keeps an item that alone exceeds `maxKB` isolated in its own batch so the server rejects it and the queue continues to drain. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…the queue
chunk()assigned batches by index (chunks[++currentChunk] = [item]). When the first item alone was>= maxKB,currentChunkwent 0 -> 1 and index 0 was never written, producing a sparse array. Since 2.23.0 the upload path iterates batch results withfor...of, which does not skip holes, soaggregateErrorsread.statusoffundefinedand every flush threw. The throw escapessendEventsafter the upload but beforeprocessUploadResults, so nothing is ever dequeued and the queue only recovers whenpruneExpiredEventsdiscards the events 12 hours later.rollingKBSizewas also never reset when a new chunk started, so once the cumulative size crossedmaxKBevery remaining item became its own batch and thecountlimit became unreachable.Build the chunks by appending and reset the accumulator per chunk. This removes the hole, restores the
countlimit, and keeps an item that alone exceedsmaxKBisolated in its own batch so the server rejects it and the queue continues to drain.