Support AbortSignal for cancellation
RangerMauve opened this issue · comments
Node 15 is supporting AbortController and AbortSignal for cancellation.
This seems like it's going to be the standard for JS in both Node and Web Browsers and is already being added to APIs like fs.readFile.
It'd be nice to be able to supplement the opts.cancel pattern that's currently in place.
The streams have abortcontroller support so would be good to have it here I agree
Sessions make this pretty easy now
@mafintosh Mind elaborating a bit on how AbortController could be used with Sessions? Would a PR with some docs on that be welcome?
So with sessions you can do this:
const s = core.session()
const p = s.get(...)
await s.close() // cancels the promise above if it hasn't been fulfilled
ie, closing a session cancels all pending io, started on that session