Skip to content

fix(core): build chunks by appending so oversized events don't stall … - #1318

Open
abueide wants to merge 1 commit into
masterfrom
fix/issue-1309
Open

fix(core): build chunks by appending so oversized events don't stall …#1318
abueide wants to merge 1 commit into
masterfrom
fix/issue-1309

Conversation

@abueide

@abueide abueide commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

…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.

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants