Skip to content

stream: add abort signal for ReadableStream and WritableStream - #46273

Merged
nodejs-github-bot merged 13 commits into
nodejs:mainfrom
debadree25:ft/add-abort-signal-webstreams
Feb 17, 2023
Merged

stream: add abort signal for ReadableStream and WritableStream#46273
nodejs-github-bot merged 13 commits into
nodejs:mainfrom
debadree25:ft/add-abort-signal-webstreams

Conversation

@debadree25

Copy link
Copy Markdown
Contributor

Refs: #39316

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. web streams labels Jan 19, 2023
Comment threadlib/internal/streams/utils.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we using Symbol.for here?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I used the similar pattern to what we followed over here #46205 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@aduh95 I presume Node.js streams or another part that exists both in core and userland added this for interoperability (so that require("node:stream") and require("readable-stream") interoperate) and then everyone (probably me too) saw the code and cargo culted. Probably a bunch at the point we moved private variables to symbols when privates were not supported in snapshots back then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's also arguably easier to debug "from the outside" but not by a considerable margin.

Comment threadlib/internal/webstreams/readablestream.js Outdated
Comment threadlib/internal/streams/add-abort-signal.js Outdated
Comment threadlib/internal/webstreams/writablestream.js Outdated
Comment threadtest/parallel/test-webstreams-abort-controller.js Outdated
Comment threadtest/parallel/test-webstreams-abort-controller.js Outdated
@debadree25

Copy link
Copy Markdown
ContributorAuthor

Added more few more tests should be covering most scenarios

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@aduh95aduh95 mentioned this pull request Jan 22, 2023

@benjamingrbenjamingr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Neat (I'm +1 on this and approving). I'll add some questions later.

@benjamingr

Copy link
Copy Markdown
Member

Hey, consider going through the standards track and adding this to streams through WHATAG (like a signal parameter to the constructor). This is not instead of this PR but in addition.

@benjamingrbenjamingr added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 22, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 22, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@benjamingr

Copy link
Copy Markdown
Member

Can you also please add to the docs for addAbortSignal at stream.md ?

@jasnell

jasnell commented Jan 22, 2023

Copy link
Copy Markdown
Member

The docs for addAbortSignal needs to be updated also

Heh, jinx.

@debadree25

Copy link
Copy Markdown
ContributorAuthor

Can you also please add to the docs for addAbortSignal at stream.md ?

Adding!

@debadree25

Copy link
Copy Markdown
ContributorAuthor

Hey, consider going through the standards track and adding this to streams through WHATAG (like a signal parameter to the constructor). This is not instead of this PR but in addition.

Hi so are you thinking something like new ReadableStream({ signal: ac.signal })

@jasnell

Copy link
Copy Markdown
Member

Adding a signal to the ReadableStream constructor is not something I would really expect to see happen in whatwg, particularly since there is already a way of cancelling the stream via the existing API. Could be worth a try but I'd be surprised if it were accepted.

@debadree25

Copy link
Copy Markdown
ContributorAuthor

Have added to docs @benjamingr@jasnell

Comment threaddoc/api/stream.md Outdated
Comment threaddoc/api/stream.md Outdated

@aduh95aduh95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add an history entry in the YAML comment please?

@aduh95aduh95 added the semver-minor PRs that contain new features and should be released in the next minor version. label Jan 23, 2023
@debadree25

Copy link
Copy Markdown
ContributorAuthor

What should the version be v19.5.0?

@aduh95

Copy link
Copy Markdown
Contributor

What should the version be v19.5.0?

It should be REPLACEME:

`vcbuild.bat lint` on Windows). If you are adding to or deprecating an API,
add or change the appropriate YAML documentation. Use `REPLACEME` for the
version number in the documentation YAML:
```markdown
### `request.method`
<!-- YAML
added: REPLACEME
-->
* {string} The request method.
```

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@debadree25

debadree25 commented Feb 7, 2023

Copy link
Copy Markdown
ContributorAuthor

could this have another CI run? the macOS failure seems unrelated

@mcollinamcollina added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Feb 17, 2023

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 17, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 96c720e into nodejs:mainFeb 17, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 96c720e

MylesBorins pushed a commit that referenced this pull request Feb 18, 2023
Refs: #39316
PR-URL: #46273
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins added a commit that referenced this pull request Feb 19, 2023
Notable changes:
deps:
* upgrade npm to 9.5.0 (npm team) #46673
* add ada as a dependency (Yagiz Nizipli) #46410
doc:
* add debadree25 to collaborators (Debadree Chatterjee) #46716
* add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
* rename --test-coverage (Colin Ihrig) #46017
lib:
* (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
* (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
* (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
* (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
* (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
* (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
* (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
* (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
* (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
* add initial code coverage support (Colin Ihrig) #46017
url:
* replace url-parser with ada (Yagiz Nizipli) #46410
PR-URL: TODO
@MylesBorinsMylesBorins mentioned this pull request Feb 19, 2023
MylesBorins added a commit to MylesBorins/node that referenced this pull request Feb 20, 2023
Notable changes:
deps:
* upgrade npm to 9.5.0 (npm team) nodejs#46673
* add ada as a dependency (Yagiz Nizipli) nodejs#46410
doc:
* add debadree25 to collaborators (Debadree Chatterjee) nodejs#46716
* add deokjinkim to collaborators (Deokjin Kim) nodejs#46444
doc,lib,src,test:
* rename --test-coverage (Colin Ihrig) nodejs#46017
lib:
* (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) nodejs#46494
src:
* (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) nodejs#45038
* (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) nodejs#46583
* (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) nodejs#46491
* (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) nodejs#45888
* (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) nodejs#45888
* (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) nodejs#45888
* (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) nodejs#46368
stream:
* (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) nodejs#46273
test_runner:
* add initial code coverage support (Colin Ihrig) nodejs#46017
url:
* replace url-parser with ada (Yagiz Nizipli) nodejs#46410
PR-URL: nodejs#46725
MylesBorins added a commit that referenced this pull request Feb 20, 2023
Notable changes:
deps:
* upgrade npm to 9.5.0 (npm team) #46673
* add ada as a dependency (Yagiz Nizipli) #46410
doc:
* add debadree25 to collaborators (Debadree Chatterjee) #46716
* add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
* rename --test-coverage (Colin Ihrig) #46017
lib:
* (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
* (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
* (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
* (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
* (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
* (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
* (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
* (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
* (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
* add initial code coverage support (Colin Ihrig) #46017
url:
* replace url-parser with ada (Yagiz Nizipli) #46410
PR-URL: #46725
MylesBorins pushed a commit that referenced this pull request Feb 20, 2023
Refs: #39316
PR-URL: #46273
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins added a commit that referenced this pull request Feb 20, 2023
Notable changes:
deps:
* upgrade npm to 9.5.0 (npm team) #46673
* add ada as a dependency (Yagiz Nizipli) #46410
doc:
* add debadree25 to collaborators (Debadree Chatterjee) #46716
* add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
* rename --test-coverage (Colin Ihrig) #46017
lib:
* (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
* (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
* (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
* (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
* (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
* (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
* (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
* (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
* (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
* add initial code coverage support (Colin Ihrig) #46017
url:
* replace url-parser with ada (Yagiz Nizipli) #46410
PR-URL: #46725
MylesBorins added a commit that referenced this pull request Feb 21, 2023
Notable changes:
deps:
* upgrade npm to 9.5.0 (npm team) #46673
* add ada as a dependency (Yagiz Nizipli) #46410
doc:
* add debadree25 to collaborators (Debadree Chatterjee) #46716
* add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
* rename --test-coverage (Colin Ihrig) #46017
lib:
* (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
* (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
* (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
* (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
* (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
* (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
* (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
* (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
* (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
* add initial code coverage support (Colin Ihrig) #46017
url:
* replace url-parser with ada (Yagiz Nizipli) #46410
PR-URL: #46725
debadree25 added a commit to debadree25/node that referenced this pull request Feb 27, 2023
Refs: nodejs#39316
PR-URL: nodejs#46273
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams pushed a commit that referenced this pull request Apr 11, 2023
Refs: #39316
PR-URL: #46273
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams added a commit that referenced this pull request Apr 11, 2023
Notable changes:
* buffer:
* (SEMVER-MINOR) add Buffer.copyBytesFrom(...) (James M Snell) #46500
* doc:
* add marco-ippolito to collaborators (Marco Ippolito) #46816
* add debadree25 to collaborators (Debadree Chatterjee) #46716
* add deokjinkim to collaborators (Deokjin Kim) #46444
* events:
* (SEMVER-MINOR) add listener argument to listenerCount (Paolo Insogna) #46523
* lib:
* (SEMVER-MINOR) add AsyncLocalStorage.bind() and .snapshot() (flakey5) #46387
* (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
* src:
* (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
* (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
* stream:
* (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
* tls:
* (SEMVER-MINOR) support automatic DHE (Tobias Nießen) #46978
* url:
* (SEMVER-MINOR) implement URLSearchParams size getter (James M Snell) #46308
* worker:
* (SEMVER-MINOR) add support for worker name in inspector and trace_events (Debadree Chatterjee) #46832
PR-URL: #47502
danielleadams added a commit that referenced this pull request Apr 11, 2023
Notable changes:
* buffer:
* (SEMVER-MINOR) add Buffer.copyBytesFrom(...) (James M Snell) #46500
* doc:
* add marco-ippolito to collaborators (Marco Ippolito) #46816
* add debadree25 to collaborators (Debadree Chatterjee) #46716
* add deokjinkim to collaborators (Deokjin Kim) #46444
* events:
* (SEMVER-MINOR) add listener argument to listenerCount (Paolo Insogna) #46523
* lib:
* (SEMVER-MINOR) add AsyncLocalStorage.bind() and .snapshot() (flakey5) #46387
* (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
* src:
* (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
* (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
* (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
* stream:
* (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
* tls:
* (SEMVER-MINOR) support automatic DHE (Tobias Nießen) #46978
* url:
* (SEMVER-MINOR) implement URLSearchParams size getter (James M Snell) #46308
* worker:
* (SEMVER-MINOR) add support for worker name in inspector and trace_events (Debadree Chatterjee) #46832
PR-URL: #47502
danielleadams added a commit that referenced this pull request Apr 12, 2023
Notable changes:
Add initial support for single executable applications
Compile a JavaScript file into a single executable application:
```console
$ echo 'console.log(`Hello, ${process.argv[2]}!`);' > hello.js
$ cp $(command -v node) hello
$ npx postject hello NODE_JS_CODE hello.js \
--sentinel-fuse NODE_JS_FUSE_fce680ab2cc467b6e072b8b5df1996b2
$ npx postject hello NODE_JS_CODE hello.js \
--sentinel-fuse NODE_JS_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
--macho-segment-name NODE_JS
$ ./hello world
Hello, world!
```
Contributed by Darshan Sen in #45038
Replace url parser with Ada
Node.js gets a new URL parser called Ada that is compliant with the WHATWG
URL Specification and provides more than 100% performance improvement to
the existing implementation.
Contributed by Yagiz Nizipli in #46410
Other notable changes:
* buffer:
* (SEMVER-MINOR) add Buffer.copyBytesFrom(...) (James M Snell) #46500
* doc:
* add marco-ippolito to collaborators (Marco Ippolito) #46816
* add debadree25 to collaborators (Debadree Chatterjee) #46716
* add deokjinkim to collaborators (Deokjin Kim) #46444
* events:
* (SEMVER-MINOR) add listener argument to listenerCount (Paolo Insogna) #46523
* lib:
* (SEMVER-MINOR) add AsyncLocalStorage.bind() and .snapshot() (flakey5) #46387
* (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
* src:
* (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
* (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
* stream:
* (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
* tls:
* (SEMVER-MINOR) support automatic DHE (Tobias Nießen) #46978
* url:
* (SEMVER-MINOR) implement URLSearchParams size getter (James M Snell) #46308
* worker:
* (SEMVER-MINOR) add support for worker name in inspector and trace_events (Debadree Chatterjee) #46832
PR-URL: #47502
danielleadams added a commit that referenced this pull request Apr 13, 2023
Notable changes:
Add initial support for single executable applications
Compile a JavaScript file into a single executable application:
```console
$ echo 'console.log(`Hello, ${process.argv[2]}!`);' > hello.js
$ cp $(command -v node) hello
$ npx postject hello NODE_JS_CODE hello.js \
--sentinel-fuse NODE_JS_FUSE_fce680ab2cc467b6e072b8b5df1996b2
$ npx postject hello NODE_JS_CODE hello.js \
--sentinel-fuse NODE_JS_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
--macho-segment-name NODE_JS
$ ./hello world
Hello, world!
```
Contributed by Darshan Sen in #45038
Replace url parser with Ada
Node.js gets a new URL parser called Ada that is compliant with the WHATWG
URL Specification and provides more than 100% performance improvement to
the existing implementation.
Contributed by Yagiz Nizipli in #46410
Other notable changes:
* buffer:
* (SEMVER-MINOR) add Buffer.copyBytesFrom(...) (James M Snell) #46500
* doc:
* add marco-ippolito to collaborators (Marco Ippolito) #46816
* add debadree25 to collaborators (Debadree Chatterjee) #46716
* add deokjinkim to collaborators (Deokjin Kim) #46444
* events:
* (SEMVER-MINOR) add listener argument to listenerCount (Paolo Insogna) #46523
* lib:
* (SEMVER-MINOR) add AsyncLocalStorage.bind() and .snapshot() (flakey5) #46387
* (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
* src:
* (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
* (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
* stream:
* (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
* tls:
* (SEMVER-MINOR) support automatic DHE (Tobias Nießen) #46978
* url:
* (SEMVER-MINOR) implement URLSearchParams size getter (James M Snell) #46308
* worker:
* (SEMVER-MINOR) add support for worker name in inspector and trace_events (Debadree Chatterjee) #46832
PR-URL: #47502
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.needs-ciPRs that need a full CI run.semver-minorPRs that contain new features and should be released in the next minor version.web streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@debadree25@nodejs-github-bot@benjamingr@jasnell@aduh95@mcollina@lpinca