GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: implement ReadableStream.from by debadree25 · Pull Request #48395 · nodejs/node

Conversation

@debadree25

@debadree25 debadree25 commented Jun 8, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Implements ReadableStream.from

Updating the WPTs add a lot of new tests, and failures that weren't relevant to this PR, I have added them to expected failures.

Please do take a look at the node errors used, I have used ERR_INVALID_STATE.TypeError in all the places since all the webstreams code seems to be reliant on that.

Fixes: #48389

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss and lin72h reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. web streams Issues and PRs related to the Web Streams API. labels Jun 8, 2023
@debadree25
debadree25 marked this pull request as ready for review June 8, 2023 18:29
@debadree25
debadree25 force-pushed the ft/readablestream-from branch from 48a8af4 to cee7a5a Compare June 8, 2023 18:39
@debadree25

debadree25 commented Jun 8, 2023

Copy link
Copy Markdown
Contributor Author

cc @nodejs/whatwg-stream

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@debadree25

debadree25 commented Jun 8, 2023

Copy link
Copy Markdown
Contributor Author

Also, would this need node tests too? or WPTs are enough?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@debadree25 debadree25 added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jun 8, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jun 8, 2023
@nodejs-github-bot

nodejs-github-bot commented Jun 8, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/52169/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina approved these changes Jun 8, 2023
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The 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.

debadree25 and lin72h reacted with heart emoji debadree25 and lin72h reacted with rocket emoji
All reactions
  • ❤️ 2 reactions
  • 🚀 2 reactions
@debadree25 debadree25 added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jun 8, 2023
KhafraDev
KhafraDev approved these changes Jun 8, 2023
View reviewed changes
benjamingr
benjamingr reviewed Jun 8, 2023
View reviewed changes
Comment thread lib/internal/webstreams/readablestream.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

benjamingr
benjamingr reviewed Jun 8, 2023
View reviewed changes
Comment thread lib/internal/webstreams/readablestream.js Outdated

@benjamingr benjamingr Jun 8, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be an async function which would allow the catch to not exist nd the below return PromiseResolve() to just be a return etc?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@debadree25 debadree25 Jun 9, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm i think it could, let me make it so and see if the WPTs pass

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@debadree25 debadree25 Jun 9, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! updated this, the WPTs don't complain and reading the spec i doesn't seem to say anything about the function having to sync or async

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@MattiasBuelens MattiasBuelens Jun 26, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this is equivalent. I wanted the error handling to be very explicit in the reference implementation, but practical implementations can be more succinct. 🙂

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
benjamingr
benjamingr approved these changes Jun 8, 2023
View reviewed changes

@benjamingr benjamingr left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM (esp for a first version).

A few notes:

  • We can simplify this a bit with async functions
  • We should short circuit if we get a Node stream and use toWeb machinary if the spec allows

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot mentioned this pull request Jun 9, 2023
CI Reliability 2023-06-09 nodejs/reliability#588
Open
24 tasks
marco-ippolito
marco-ippolito reviewed Jun 9, 2023
View reviewed changes
Comment thread lib/internal/webstreams/util.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@debadree25

debadree25 commented Jun 9, 2023

Copy link
Copy Markdown
Contributor Author

We should short circuit if we get a Node stream and use toWeb machinary if the spec allows

where to check for this? should make a issue on the spec repo? maybe @MattiasBuelens can help?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@debadree25

debadree25 commented Jun 9, 2023

Copy link
Copy Markdown
Contributor Author

have addressed all the comments and will wait for some time if we would like to add .toWeb functionality like @benjamingr suggested

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@debadree25 debadree25 added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Jun 9, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jun 9, 2023
@nodejs-github-bot

nodejs-github-bot commented Jun 9, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/52185/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Jun 10, 2023
CI Reliability 2023-06-10 nodejs/reliability#589
Open
23 tasks
aduh95
aduh95 reviewed Jun 10, 2023
View reviewed changes
Comment thread lib/internal/webstreams/util.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jun 11, 2023
CI Reliability 2023-06-11 nodejs/reliability#590
Open
CI Reliability 2023-06-12 nodejs/reliability#591
Open
@MattiasBuelens

MattiasBuelens commented Jun 12, 2023

Copy link
Copy Markdown
Contributor

We should short circuit if we get a Node stream and use toWeb machinary if the spec allows

where to check for this? should make a issue on the spec repo? maybe @MattiasBuelens can help?

I would recommend something like:

// at the top-level
// ideally, this is exported by `lib/internal/streams/readable.js`
const originalReadableAsyncIterator = Readable.prototype[Symbol.asyncIterator];

// in readableStreamFromIterable
if (iterable instanceof Readable && iterable[Symbol.asyncIterator] === originalReadableAsyncIterator) {
 return Readable.toWeb(iterable);
}

This way, you can be certain that you're dealing with an unmodified Readable, and that there will be no behavioral differences compared to "going the long way" using Readable's async iterator.

I also suggest you write additional tests with polluted Readable instances, or with a polluted Readable.prototype. 😉

debadree25 reacted with heart emoji debadree25 reacted with rocket emoji
All reactions
  • ❤️ 1 reaction
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Jun 13, 2023
CI Reliability 2023-06-13 nodejs/reliability#592
Open
22 tasks
@debadree25

debadree25 commented Jun 13, 2023

Copy link
Copy Markdown
Contributor Author

Hey one thing is it ok to export things from lib/internal/streams/readable.js something like originalReadableAsyncIterator as suggested? i know there is little bit restrictions in what we can export import in around the readable node stream part since its used in readablestream @benjamingr @mcollina

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 13, 2023
@nodejs-github-bot

nodejs-github-bot commented Jul 13, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/52751/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Jul 13, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/52752/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@debadree25
stream: implement ReadableStream.from
ef12c54
Fixes: nodejs#48389
@debadree25
debadree25 force-pushed the ft/readablestream-from branch from bfefd98 to ef12c54 Compare July 13, 2023 18:30
@debadree25 debadree25 added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 13, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 13, 2023
@nodejs-github-bot

nodejs-github-bot commented Jul 13, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/52753/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@debadree25

debadree25 commented Jul 14, 2023

Copy link
Copy Markdown
Contributor Author

Hello everyone! I have reverted the change of toWeb for now (I shall do it in a follow up, since i was getting confused 😅) PTAL it seems ready to land!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@debadree25
debadree25 requested review from benjamingr and mcollina July 14, 2023 06:53
@debadree25 debadree25 removed the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Jul 14, 2023
This was referenced Jul 16, 2023
CI Reliability 2023-07-16 nodejs/reliability#614
Open
CI Reliability 2023-07-17 nodejs/reliability#615
Open
benjamingr
benjamingr approved these changes Jul 18, 2023
View reviewed changes
@debadree25 debadree25 added author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue PRs queued for automated landing through the Commit Queue. labels Jul 18, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Jul 18, 2023
@nodejs-github-bot
nodejs-github-bot merged commit b361ad7 into nodejs:main Jul 18, 2023
@nodejs-github-bot

nodejs-github-bot commented Jul 18, 2023

Copy link
Copy Markdown
Collaborator

Landed in b361ad7

MattiasBuelens, lin72h, and benjamingr reacted with rocket emoji
All reactions
  • 🚀 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MattiasBuelens MattiasBuelens mentioned this pull request Jul 20, 2023
Support ReadableStream.from() oven-sh/bun#3700
Closed
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
@debadree25 @Ceres6
stream: implement ReadableStream.from
0a36a9b
Fixes: nodejs#48389
PR-URL: nodejs#48395
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
@debadree25 @Ceres6
stream: implement ReadableStream.from
4407d26
Fixes: nodejs#48389
PR-URL: nodejs#48395
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
UlisesGascon pushed a commit to UlisesGascon/node that referenced this pull request Aug 14, 2023
@debadree25 @UlisesGascon
stream: implement ReadableStream.from
bc6f860
Fixes: nodejs#48389
PR-URL: nodejs#48395
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 15, 2023
@debadree25 @RafaelGSS
stream: implement ReadableStream.from
609b25f
Fixes: #48389
PR-URL: #48395
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@UlisesGascon UlisesGascon mentioned this pull request Aug 15, 2023
v20.6.0 proposal #49185
Merged
@mcollina mcollina mentioned this pull request Sep 8, 2023
regression: Response does not accept a async-iterator anymore #49551
Closed
@jcbhmr jcbhmr mentioned this pull request Nov 3, 2023
api.ReadableStream.from_static - nodejs/deno versions mdn/browser-compat-data#21152
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@MattiasBuelens MattiasBuelens MattiasBuelens left review comments
@aduh95 aduh95 aduh95 left review comments
@marco-ippolito marco-ippolito marco-ippolito left review comments
@benjamingr benjamingr benjamingr approved these changes
@KhafraDev KhafraDev Awaiting requested review from KhafraDev
@mcollina mcollina Awaiting requested review from mcollina

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. needs-ci PRs that need a full CI run. web streams Issues and PRs related to the Web Streams API.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Streams: support ReadableStream.from()

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@debadree25 @nodejs-github-bot @MattiasBuelens @KhafraDev @mcollina @benjamingr @aduh95 @marco-ippolito
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.