-
Notifications
You must be signed in to change notification settings - Fork 12
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
Host hook-based cancellation #31
Comments
I don't see how that's a good idea. Will this mean that all JS engines are going to implement the
This is a big vague. I mean, I understand the goal of simple integration of ECMA-262 with host code, but how/where is ECMAScript actually going to use cancellation? How could I write ECMAScript code that should be cancellable in a standard way, if all the concrete cancellation signal objects are host-dependent? |
All (well most) JS environments implement AbortSignal/AbortController (browsers/node/workers/deno/etc) - that's one of the incentives for a hook based approach. No one really likes AbortSignal/AbortController very much but iterating on it and improving it is very doable.
That's probably for future proposals but there are plenty of places (like
You could not unless composing existing cancellable things from the language or platform. Note this is still an improvement since currently you both cannot cancel your own ongoing things (in the language) or the language's - this approach makes the latter possible. |
I think I don't get the point of specifying these hooks and abstract operations, if ECMA-262 is not actually going to call them. It feels backwards - normally there is a design of how a new ECMAScript code (syntax/builtin function) should work, then abstract operations are defined to describe that behaviour in the necessary spec abstraction. We don't start with records and abstract operations only to see what we can then build from them - without a concrete use case I can't judge whether they're adequate.
I don't understand how that's an incentive. Why wouldn't we then just specify But still, if that's the reason, a protocol-based approach seems far superior - What is the direction in which you want to iterate?
I know plenty of these places :-) However, taking the dynamic Is an AbortCapability only meant for communication with the host? E.g. specifying an But again, without seeing examples of where something like |
I'm wondering, if we're not choosing a symbol protocol, how can membrane emulate a signal in another realm. |
As explained above - there are multiple places where they can be called - note this is a stage 1 proposal and the discussion about the idea. What Ron wrote above isn't "the final spec text" it's an idea.
Because it would require specifying
Simply put because Chrome don't want two cancellation primitives and are blocking this - that's what's currently blocking the protocol based approach. I can understand that sentiment (users don't care where things are specified and they don't want them to have to cancellation primitives).
Making AbortSignal better by supporting things like |
Ah, thanks @benjamingr, I think that makes the picture a bit clearer. So the goal really is to pass an
Oh wait I was wrong there.
Are Chrome fundamentally opposed to a symbol-based protocol, or are they just trying to avoid having both |
A few thoughts
In general I think this hook approach seems promising, and would slot into existing implementations. |
The last time we looked at this, we were considering a symbol-based protocol in #22. @domenic suggested that we instead consider a host-hook based approach.
Part of this will be determining what the goals of this approach are, and where the boundaries between ECMA-262 and the Host should be:
Goals
Promise
can be used internally.Boundaries
While this is still a fairly early draft, the following is a rough outline of what I'm considering for a host-hook based implementation. I've also tentatively outlined
PreventAbort
, a capability I would like to have in a cancellation signal implementation to perform cleanup when an algorithm no longer has need of a cancellation signal, and thus it can be garbage collected. There's more I'd like to add to this relating to linking cancellation sources so that entire cancellation graphs clean up references and allow GC, but for now considerPreventAbort
to be mostly a stub definition to be expanded later.Records
AbortCapability Record
AbortReaction Record
Algorithms
CreateAbortCapability()
HostInitializeAbortCapability(capability: an AbortCapability Record)
AddAbortReaction(capability: an AbortCapability Record, handler: a Function object)
RemoveAbortReaction(capability: an AbortCapability Record, reaction: an AbortReaction Record)
Abort(capability: an AbortCapability Record, reason: an ECMAScript language value)
HostSetAbortReason(capability: an AbortCapability Record, reason: an ECMAScript language value)
TriggerAbortReactions(reactions: A List of AbortReaction Records)
PreventAbort(capability: an AbortCapability Record)
HostPreventAbort(capability: an AbortCapability Record)
GetAbortCapability(object: an Object)
HostGetAbortCapability(object: an Object)
The text was updated successfully, but these errors were encountered: