Open
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()
}