-
-
Notifications
You must be signed in to change notification settings - Fork 35k
Open
Labels
abortcontrollerIssues and PRs related to the AbortController APIIssues and PRs related to the AbortController APIhttpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
We currently have several APIs that support AbortSignals like:
- http.Server
- stream.Readable / stream.Writable
- child_process methods returning a child (and not a promise)
- addAbortSignal
Those APIs are resources and not actions and support Symbol.dispose Symbol.asyncDispose.
Since they are disposables, we should deprecate support for AbortSignal on APIs that are resources and not actions (while keeping AbortSignal on APIs that are actions (e.g. return promises)) and encourage the safe helper we added for addAbortListener on those updating our docs.
Basically instead of:
function foo() {
const ac = new AbortController();
const httpServer = /* */
httpServer.listen(3000, { signal: ac.signal });
return someAsyncAction().then(() => ac.abort()); // close the server
}We should encourage:
async function foo() {
using httpServer = /* */
httpServer.listen(3000);
await someAsyncAction()
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
abortcontrollerIssues and PRs related to the AbortController APIIssues and PRs related to the AbortController APIhttpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.