-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancellation APIs #10181
Comments
I saw there was a PR merged for this feature for How do you propose that it would be implemented? Would it cause a sync function to throw (or an async function to reject with) a DOMException for all supported functions? |
I actually authored that PR (and co-authored that feature in the DOM). If docs/types are missing I am happy to contribute those as well.
Basically, yes. Go through all APIs that are cancellable/disposable and add support using the WHATWG/dom guidance (add a Note there is very little (if at all) value to add this to sync APIs IMO :) |
It wouldn't be possible to add to sync APIs anyway, because how would you trigger the abort while the event loop is blocked 😉. |
I'm glad you asked 😅 Technically (and I know this sounds odd, but this was discussed in the Atomics.waitAsync discussions) you could:
That is not worth the time, effort, maintenance, spec work or mental capacity though IMO :D |
I don't think it is possible even if we had a shareable Regarding async cancellable operations: Generally I am in favor of this. I think it makes sense to be able to cancel certain operations (like async read from a net socket). |
Send a signal? |
What would be a good way to have a discussion about this? It seems like if I start adding APIs to stuff like I'd at least like the core team (or whoever is in charge) to discuss this first :) I am happy to show up to the meeting to discuss what I'm suggesting based on work in Node and in the DOM spec if that helps. |
Kind ping |
We have Generally still in favor of this, but we should discuss which APIs it makes sense for. My current list of initial candidates:
We could start by implementing these to only cancel the internal buffering. This would negate the need to implement cancellation of All of the above APIs would need to get an options bag. |
@lucacasonato so a good way forward if I want to promote this is to PR adding |
Yup, that works for me :-) We can hash out any details in a PR. |
Ok, got 30m today going to tackle the next one now that readFile is in |
I would also like this but for reading bytes on a TCP socket via The e.g. For a simple telnet-like app I want to read incoming bytes but bail after some set amount of time |
@mfulton26 I'm not deno core I just contribute from time to time to keep up so take my answer with a grain of salt: It absolutely makes sense for |
I think also about the ergonomics of |
I'd like to see We can't create such APIs though without the underlying APIs exposing the functionality. I'm glad this issue is being tracked here. Do we have any ideas on timeline for this? I have written workaround code for now that leaves |
I would also like this for |
Hey,
It would be really cool if Deno aligned with the web platform's cancellation primitive AbortSignal/AbortController which Deno already supports but not in most of its APIs.
Myself and a few others have been adding support for AbortSignal to all of the APIs it fits in Node.js to make it easier for people to write universal JavaScript code. For example:
And more generally - in Deno's stream abstractions. Would you be open to adding this?
(Sorry for not being too available on Discord with the baby/health stuff/new job :))
The text was updated successfully, but these errors were encountered: