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.disposeSymbol.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:
functionfoo(){constac=newAbortController();consthttpServer=/* */httpServer.listen(3000,{signal: ac.signal});returnsomeAsyncAction().then(()=>ac.abort());// close the server}We should encourage:
asyncfunctionfoo(){usinghttpServer=/* */httpServer.listen(3000);awaitsomeAsyncAction()}
We currently have several APIs that support AbortSignals like:
Those APIs are resources and not actions and support
Symbol.disposeSymbol.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
addAbortListeneron those updating our docs.Basically instead of:
We should encourage: