Skip to content

Fix parsing stream with first token size > parser's chunk size-4#45

Open
n-peugnet wants to merge 2 commits into
bzick:masterfrom
n-peugnet:issue-44-long-first-token
Open

Fix parsing stream with first token size > parser's chunk size-4#45
n-peugnet wants to merge 2 commits into
bzick:masterfrom
n-peugnet:issue-44-long-first-token

Conversation

@n-peugnet

@n-peugnet n-peugnet commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

When (first token size) > (parser's chunk size-4), the next chunks are
loaded during the parsing of the first token. This triggers the end of
the parsing loop, leaving the frist token as the only one parsed, and
thus having its "next" field set to nil. This in turn, lead
Stream.GoNext() to detect the end of the stream.

To fix this, Stream.GoNext() now starts by checking the next field of
the current token, parsing the current chunk if needed, before deciding
if the end of the stream is reached.

A test is also added to prevent regressions.

Fixes #44

@n-peugnet n-peugnet force-pushed the issue-44-long-first-token branch 2 times, most recently from ea7179b to 84c07ed Compare July 7, 2026 12:57
@n-peugnet n-peugnet force-pushed the issue-44-long-first-token branch from 84c07ed to eab3a71 Compare July 7, 2026 13:47
When (first token size) > (parser's chunk size-4), the next chunks are
loaded during the parsing of the first token. This triggers the end of
the parsing loop, leaving the frist token as the only one parsed, and
thus having its "next" field set to nil. This in turn, lead
Stream.GoNext() to detect the end of the stream.

To fix this, Stream.GoNext() now starts by checking the next field of
the current token, parsing the current chunk if needed, before deciding
if the end of the stream is reached.

Fixes bzick#44
@n-peugnet n-peugnet changed the title Failing test for issue 44 Fix parsing stream with first token >= to parser's buffer Jul 7, 2026
@n-peugnet n-peugnet marked this pull request as ready for review July 7, 2026 16:30
@n-peugnet n-peugnet changed the title Fix parsing stream with first token >= to parser's buffer Fix parsing stream with first token >= to parser's chunk size-4 Jul 7, 2026
@n-peugnet n-peugnet changed the title Fix parsing stream with first token >= to parser's chunk size-4 Fix parsing stream with first token size > parser's chunk size-4 Jul 7, 2026
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.

Stops parsing after first token if its size is very close to the size of the parser's buffer

1 participant