Repository navigation
fix(core): part of a Blob read as a stream ends where it was asked to, on any runtime - #52
Merged
Merged
Conversation
…, on any runtime
On Bun 1.3 the stream of a Blob slice runs on to the end of the whole Blob.
A stored ZIP entry is read to the end of its stream, so its checksum covered
the rest of the file: every .odt failed to open ("the part “mimetype” does
not unpack correctly") and 5 tests of test/legacy-odt.test.ts failed there.
BlobSource.stream() now cuts its stream at the length asked for and cancels
what would still come, whatever the runtime sends.
Fixes #49
Co-Authored-By: Claude Fable 5.2 <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.
Fixes #49.
What was wrong
On Bun 1.3.6 the stream of a Blob slice does not stop at the end of the slice:
blob.slice(10, 49).stream()gives 990 bytes of a 1000-byte Blob (39 on Bun 1.4.4 and Node). A stored ZIP entry is read to the end of its stream, so the checksum of an.odt'smimetypecovered the rest of the file and every.odtfailed to open there.The change
BlobSource.stream()cuts its stream at the length asked for and cancels what would still come, whatever the runtime sends. Noenginesrequirement: a server package (#43) does not have to rely on the runtime here.The other
.stream()calls insrc/coreread a whole Blob, not a slice, and are not affected.Tests
New
test/blob-source.test.ts: a Blob whose slice streams run on to the end, as on Bun 1.3, so the case is tested on every runtime; empty chunks; cancelling; a stored ZIP entry followed by others, read throughZipArchiveagainst its checksum.source.tstest/blob-source.test.tstest/legacy-odt.test.ts🤖 Generated with Claude Code