| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
That's awesome, I'm going to check this out and play with it asap. Also post it on the summit issue. |
Sorry, something went wrong.
There was a problem hiding this comment.
cc @mysticatea <3
Sorry, something went wrong.
|
Other than test and review this is there anything I can do to help? |
Sorry, something went wrong.
One of the next steps is to identify a list of the existing Promise APIs in core that could by updated to make use of this. Not all of them will make sense because not all of them are abortable (e.g. libuv only allows us to cancel file system requests if they have not already been started, for instance). So while we may be able to use AbortController for fs.promises.readFile() (which performs a sequence of discreet read operations) it won't for fs.promises.read() (which performs a single discreet read operation). Once we have a list of APIs for which use of AbortController makes sense, then we need to figure out the best way to incorporate it. Each will have their own set of considerations to address. Additionally, we should make it possible for custom util.promisify implementations to support AbortController. For instance, I'm playing around with the promisification of setTimeout such that it allows: const sleep = promisify(setTimeout);
const ac = new AbortController();
sleep(10000, ac);
ac.abort(); // Calls clearTimeout on abort |
Sorry, something went wrong.
|
@jasnell I've split those tasks off into an issue here: #33528 - please feel free to edit that issue as you see fit. I will start working on these one by one (on weekends mostly) and add tasks as I find them. Feel free to edit it. I want to be clear that I want to be helpful here so since you took the initiative if at any point any of the things I'm doing are frustrating just tell me and I'll stop and do whatever is helpful to the effort instead. These sorts of ongoing efforts tend to become frustrating in Node.js at times, I want to be sure that I'm not doing any toe-stepping if I can help it. |
Sorry, something went wrong.
|
Initial implementation of EventTarget in #33556. Assuming that one goes through, this PR will be modified such that AbortController.prototype.signal is an instance of EventTarget rather than EventEmitter. |
Sorry, something went wrong.
|
@benjamingr ... quick note... this is currently extending from NodeEventTarget ... in this, however, the remove listener functions are not used and the only ones we definitely need here are the on/once/addListener in order to achieve the use cases we need for AbortSignal |
Sorry, something went wrong.
|
Marking this ready for review. This does create a new global so technically may be semver-major but I have tested it with existing ecosystem polyfills and haven't seen any breakage at all. Unless there are objections from the @nodejs/tsc, I'd like to handle this as a semver-minor. It is still experimental and an experimental warning will be emitted the first time an AbortController is created. It is not behind a flag. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
AbortController impl based very closely on:
https://github.com/mysticatea/abort-controller
Marked experimental.
Global (writable, configurable)
Not currently used by any of the existing promise apis.
AbortSignal extends from EventEmitter instead of EventTarget.
Checklist