Repository navigation
Fix buffer corruption - #38
Merged
Merged
Conversation
ntkme
force-pushed
the
fix-buffer-copy
branch
from
October 23, 2026 01:56
7fa90ca to
80a1fe0
Compare
Jealrock
approved these changes
Oct 23, 2026
nex3
approved these changes
Oct 26, 2026
nex3
left a comment
Contributor
There was a problem hiding this comment.
Thanks so much for digging into this and finding the fix!
Honestly, from what I can see the only reason we are re-wrapping the buffer is to deal with the TypeScript inconsistency between
Type 'Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>'and'Buffer<ArrayBufferLike>'. From pure JS, passingmessage.dataas is without re-wrapping works just fine.
Right; since this is a user-facing API, I want to make sure that it's a consistent type, so the user doesn't have to deal with converting types (which as we can see has some weird edge cases!) themselves.
smorrisods
added a commit
to ongov/ontario-design-system
that referenced
this pull request
Nov 5, 2026
sass-embedded's sync API intermittently fails with "Invalid protobuf" on Node 24.22+ because sync-child-process <1.1.1 can hand back a corrupted stdout buffer. This broke the React library's build-css step in CI. sass-embedded allows ^1.0.2, so pin the fixed release via a workspace override until sass-embedded requires it directly. See sass/embedded-host-node#451 and sass/sync-child-process#38.
This branch was successfully deployed
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 issue is that the underneath
ArrayBuffercan sometimes be longer than the wrappingBuffer, which is a "view" on top of theArrayBuffer. If we just doBuffer.from(message.data.buffer), it may get a new view with the extra bytes (all zeros) which ends up corrupting stdout/stderr streams.The correct way to create a duplicate view is
Buffer.from(message.data.buffer, message.data.byteOffset, message.data.length).Honestly, from what I can see the only reason we are re-wrapping the buffer is to deal with the TypeScript inconsistency between
Type 'Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>'and'Buffer<ArrayBufferLike>'. From pure JS, passingmessage.dataas is without re-wrapping works just fine.