Node: 馃殌 AbortController in Node task list

Created on 23 May 2020  路  7Comments  路  Source: nodejs/node

Hey,

James started a PR at https://github.com/nodejs/node/pull/33527 and we're having a summit meeting in https://github.com/openjs-foundation/summit/issues/273 regarding adding AbortController to core.

Other than checking out the code and testing it (please do) James listed some work items in that PR when I asked and I figured it would be nice to have a list of them here.

This list is mutable. While our process is typically that collaborators don't edit each other's posts - you are welcome to add/remove/edit this list (please do!) as you see fit:

  • Core APIs:

    • [ ] [Make a list of all core APIs that can utilize AbortController and see where it makes sense.](https://docs.google.com/document/d/1OA3LVQWj7StZSL9F8zuITEssm1gB8Yws4jwT-vOHWRg/edit#)



      • [ ] API bikeshedding for core APIs.



    • [ ] Make a list of APIs where cancellation is possible with libuv. One example is fs.promise.readFile which is multiple operations (we can cancel in between) but an fs.promises.read is not discreetly cancellable.

  • [ ] Figure out how util.promisify should support cancellation, and if it does what that API should look like.
  • [ ] Figure out how to have good/debuggable AbortErrors when things go wrong.

Most helpful comment

Supporting on callback versions is certainly possible and would likely help make things more consistent.

All 7 comments

Starting to work on an Initial list of core APIs that can utilize AbortController. Please feel free to edit this everyone.

@jasnell hey just to understand, are you interested in only supporting the promise (or promisifed) versions of the APIs (at least initially) or would you like to also explore adding it to the callback versions?

(Inb4: doing one or the other does not preclude us from doing one or the other in the future)

Supporting on callback versions is certainly possible and would likely help make things more consistent.

We need to also think about abort detection,
In the browser fetch there's very vague AbortError which is DOMException with name="AbortError",
And the protocol is kinda error instanceof Error && error.name === "AbortError"
There is no direct constructor for that error
Minimal code to get it:

c = new AbortController()
p = fetch('', {signal: c.signal}).catch(e => e)
c.abort()
abortError = await p;
console.log(abortError, abortError.name, abortError.message)

@Bnaya thanks, I added it to the list, feel free to spin up a document and bikeshed there - it's not like it's half of what we do together in our 9-5 anyway :D

@ptomato would either of you be interested in taking the API bikeshedding part?

I went over some APIs? (I'm trying to figure for what APIs it makes sense but probably not how it would look like). Error are also interesting to discuss

@ptomato would either of you be interested in taking the API bikeshedding part?

Yes, definitely. I had actually already started on that for myself. There is some proof of concept in https://github.com/ptomato/node/commits/31971-abortcontroller . I don't have much time to work on it this week, but next week I can continue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Icemic picture Icemic  路  3Comments

dfahlander picture dfahlander  路  3Comments

sandeepks1 picture sandeepks1  路  3Comments

fanjunzhi picture fanjunzhi  路  3Comments

akdor1154 picture akdor1154  路  3Comments