You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With mayBeLess: true, FileTokenizer previously returned after a single physical
read, while built-in stream tokenizers combined input fragments. Consequently,
a short result could reflect file-read fragmentation rather than EOF.
Make file buffer reads and peeks fill the requested range or stop at a zero-byte
read. mayBeLess controls whether insufficient input at EOF returns the available
byte count or throws EndOfStreamError; it does not select a single physical read.
Reuse the existing file completion loop so transport fragmentation stays below
token decoding and does not require consumer-specific retry logic.
Preserve method signatures, caller-owned buffers, read-position progress, peek
positioning and zero-length behavior. Other I/O errors still propagate. This
change does not alter file cancellation policy or introduce a shared lifecycle
abstraction. Consumers must still honor the returned count at actual EOF.
Compatibility
Following a short physical read, a file request may now perform additional I/O,
return more bytes and, for reads, advance further. It may also encounter a later
I/O error where it previously returned successfully. The existing public option
allows short results but does not promise one physical read or nonblocking
completion.
Suggested release note
File buffer reads and peeks now combine short physical reads. With mayBeLess: true, requests fill the requested range or return the available
bytes at EOF instead of stopping at the first short physical read.
Summary by CodeRabbit
Bug Fixes
Buffer reads and peeks now continue across short transport fragments until the requested range is filled or EOF is reached.
When mayBeLess is enabled, a short result is allowed only at EOF; otherwise, an incomplete request at EOF reports an error.
Short results indicate how many bytes are valid. Peeks leave the cursor unchanged, while failed reads retain any progress already made.
No actionable comments were generated in the recent review.
Walkthrough
Buffer reads now continue across short reads until the requested range is filled or EOF occurs. mayBeLess permits a partial result at EOF. Tests cover fragmented streams, partial progress, and I/O errors.
FileTokenizer continues after short reads until the request is filled or a zero-byte read occurs. Documentation describes EOF handling, returned valid bytes, position behavior, and propagation of other I/O errors.
Fragmented-read and partial-progress tests test/test-buffer-limits.ts, test/test-regular-files.ts
Tests cover fragmented stream input, partial reads and peeks at EOF or after truncation, and errors after partial progress. They check returned counts, destination bytes, and tokenizer positions.
This change makes file buffer reads behave like stream reads: they keep reading until the requested range is full or the file ends. It may perform a little more I/O than before, which the PR documents. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: FileTokenizer partial-read completion is aligned with the built-in stream tokenizers. The changeset makes FileTokenizer.readBufferAt keep reading after a short read un…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: FileTokenizer partial-read completion is aligned with the built-in stream tokenizers. The changeset makes FileTokenizer.readBufferAt keep reading after a short read until the requested length is filled or EOF is reached, and updates the README, types, and tests to match. The title is specific and does not describe unrelated work.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 29ac38e and bd0b664.
Files selected for processing: 6
README.md
lib/FileTokenizer.ts
lib/stream/AbstractStreamReader.ts
lib/types.ts
test/test-buffer-limits.ts
test/test-regular-files.ts
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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
improvementImprovements to existing functionality, usability, or performance.
1 participant
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.
Align FileTokenizer partial-read completion
With
mayBeLess: true, FileTokenizer previously returned after a single physicalread, while built-in stream tokenizers combined input fragments. Consequently,
a short result could reflect file-read fragmentation rather than EOF.
Make file buffer reads and peeks fill the requested range or stop at a zero-byte
read.
mayBeLesscontrols whether insufficient input at EOF returns the availablebyte count or throws
EndOfStreamError; it does not select a single physical read.Reuse the existing file completion loop so transport fragmentation stays below
token decoding and does not require consumer-specific retry logic.
Preserve method signatures, caller-owned buffers, read-position progress, peek
positioning and zero-length behavior. Other I/O errors still propagate. This
change does not alter file cancellation policy or introduce a shared lifecycle
abstraction. Consumers must still honor the returned count at actual EOF.
Compatibility
Following a short physical read, a file request may now perform additional I/O,
return more bytes and, for reads, advance further. It may also encounter a later
I/O error where it previously returned successfully. The existing public option
allows short results but does not promise one physical read or nonblocking
completion.
Suggested release note
File buffer reads and peeks now combine short physical reads. With
mayBeLess: true, requests fill the requested range or return the availablebytes at EOF instead of stopping at the first short physical read.
Summary by CodeRabbit
mayBeLessis enabled, a short result is allowed only at EOF; otherwise, an incomplete request at EOF reports an error.