GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing github.com — stream: allow transfer of readable byte streams by mrbbot · Pull Request #45955 · nodejs/node Conversation
Contributor
Previosuly, attempting to transfer a const stream = new ReadableStream({ type: "bytes", pull(controller) { controller.enqueue(new Uint8Array([1, 2, 3])); controller.close(); }, }); const stream2 = structuredClone(stream, { transfer: [stream] }); ...would fail with... This PR updates the const stream = new ReadableStream({ type: "bytes", pull(controller) { controller.enqueue(new Uint8Array([1, 2, 3])); controller.close(); }, }); const stream2 = structuredClone(stream, { transfer: [stream] }); const reader = await stream2.getReader(); // `{ mode: "byob" }` would fail here as // `stream2` is no longer a byte stream (tested with Chrome 108.0.5359.124) Refs: #39062
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Updates the `ReadableStream` constructor to mark byte streams as transferable. When transferred, byte streams become regular streams. Refs: nodejs#39062 Refs: https://streams.spec.whatwg.org/#rs-transfer
mrbbot
added a commit
to cloudflare/miniflare
that referenced
this pull request
`5.11.0` includes nodejs/undici#1643. There are some non-trivial changes required to upgrade to `5.14.0`: - Since `[email protected]` (nodejs/undici#1697), `structuredClone` is used on bodies, which may be byte streams. Due to a Node bug (nodejs/node#45955), readable byte streams cannot be transferred, breaking `fetch`. - Since `[email protected]` (nodejs/undici#1793), global `ReadableStream` and `TransformStream` are used if available. In the Vitest environment, (which modifies the global scope unlike Jest which runs tests in a VM context), if the `streams_enable_constructors` compatibility flag isn't enabled, `fetch` breaks as `ReadableStream`s can't be constructed.
daeyeon
approved these changes
This comment was marked as outdated.
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
mcollina
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lgtm
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
benjamingr
approved these changes
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
jasnell
approved these changes
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
mcollina
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lgtm
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
This was referenced
MylesBorins
pushed a commit
that referenced
this pull request
Updates the `ReadableStream` constructor to mark byte streams as transferable. When transferred, byte streams become regular streams. Refs: #39062 Refs: https://streams.spec.whatwg.org/#rs-transfer PR-URL: #45955 Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
Merged
danielleadams
pushed a commit
that referenced
this pull request
Updates the `ReadableStream` constructor to mark byte streams as transferable. When transferred, byte streams become regular streams. Refs: #39062 Refs: https://streams.spec.whatwg.org/#rs-transfer PR-URL: #45955 Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
author ready
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. | |||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |