Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v14.x] Backport AbortController and friends #38386

Closed
Closed
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1cff8fd
lib: initial experimental AbortController implementation
jasnell May 23, 2020
c86e131
timers: allow promisified timeouts/immediates to be canceled
jasnell Jun 10, 2020
290ce9f
timers: fix multipleResolves in promisified timeouts/immediates
lundibundi Jun 18, 2020
d097171
timers: move promisified timers implementations
jasnell Jun 18, 2020
26b7626
timers: use AbortController with correct name/message
addaleax Aug 13, 2020
268686a
events: allow use of AbortController with once
jasnell Aug 24, 2020
51031f3
events: allow use of AbortController with on
jasnell Aug 24, 2020
affb52d
doc: revise AbortSignal text and example using events.once()
Trott Sep 1, 2020
561d832
doc: make AbortSignal text consistent in events.md
Trott Sep 3, 2020
b389182
events: make abort_controller event trusted
benjamingr Oct 26, 2020
f76ab5a
lib: let abort_controller target be EventTarget
watilde Oct 30, 2020
76cdf87
test: integrate abort_controller tests from wpt
watilde Oct 30, 2020
dc3d852
fs: add support for AbortSignal in readFile
benjamingr Nov 1, 2020
ceef7e3
fs: support abortsignal in writeFile
benjamingr Nov 6, 2020
01d2b67
events: add a few tests
benjamingr Oct 26, 2020
1ca549d
events: support emit on nodeeventtarget
benjamingr Oct 28, 2020
307bebc
events: define event handler as enumerable
benjamingr Nov 2, 2020
902503c
events: support event handlers on prototypes
benjamingr Nov 2, 2020
6bbd82f
events: define abort on prototype
benjamingr Nov 2, 2020
7d255e6
events: fire handlers in correct oder
benjamingr Nov 6, 2020
0131586
events: disabled manual construction AbortSignal
RaisinTen Nov 12, 2020
555a5a2
events: getEventListeners static
benjamingr Nov 6, 2020
e8bd59c
http: add support for abortsignal to http.request
benjamingr Nov 9, 2020
5ce6f91
http2: add support for AbortSignal to http2Session.request
MadaraUchiha Nov 10, 2020
8277ec1
child_process: add AbortSignal support
benjamingr Nov 28, 2020
6c86e68
test: increase execFile abort coverage
shootermv Dec 7, 2020
4f04104
child_process: clean event listener correctly
benjamingr Dec 7, 2020
44a304d
child_process: add signal support to spawn
benjamingr Dec 7, 2020
b9732d4
child_process: support AbortSignal in fork
benjamingr Dec 22, 2020
130b797
timers: refactor to use validateAbortSignal
Lxxyx Dec 22, 2020
1b04e63
dgram: support AbortSignal in createSocket
Jan 22, 2021
ef6af8c
fs: add AbortSignal support to watch
benjamingr Feb 2, 2021
88b3463
fs: fix pre-aborted writeFile AbortSignal file leak
Feb 16, 2021
a80d272
doc: recommend checking abortSignal.aborted first
jasnell Mar 11, 2021
6b3a21c
events: add max listener warning for EventTarget
jasnell Nov 6, 2020
a2cf563
lib: set abort-controller toStringTag
benjamingr Nov 14, 2020
436a2d2
lib: implement AbortSignal.abort()
jasnell Mar 10, 2021
63099e1
test: update dom/abort tests
jasnell Mar 15, 2021
10131cd
lib: add brand checks to AbortController and AbortSignal
MattiasBuelens Mar 11, 2021
9abc11a
test: fix unreliable test-fs-write-file.js
Trott Nov 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: revise AbortSignal text and example using events.once()
Add a line to the example code to clarify what happens if an event is
emitted after listening is canceled. Make minor revisions to surrounding
text.

PR-URL: #35005
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Trott authored and targos committed Apr 30, 2021

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
commit affb52d76fc3db69079d96225d7e72d0f475aa67
6 changes: 3 additions & 3 deletions doc/api/events.md
Original file line number Diff line number Diff line change
@@ -839,8 +839,7 @@ added:
* `emitter` {EventEmitter}
* `name` {string}
* `options` {Object}
* `signal` {AbortSignal} An {AbortSignal} that may be used to cancel waiting
for the event.
* `signal` {AbortSignal} Can be used to cancel waiting for the event.
* Returns: {Promise}

Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
@@ -899,7 +898,7 @@ ee.emit('error', new Error('boom'));
// Prints: ok boom
```

An {AbortSignal} may be used to cancel waiting for the event early:
An {AbortSignal} can be used to cancel waiting for the event:

```js
const { EventEmitter, once } = require('events');
@@ -922,6 +921,7 @@ async function foo(emitter, event, signal) {

foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!
```

### Awaiting multiple events emitted on `process.nextTick()`