-
Notifications
You must be signed in to change notification settings - Fork 161
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
define semantics of {source,sink}.finally() #636
Comments
Thanks for filing this. My plan for Could you explain a bit more what the benefit would be of switching to one argument? |
I think sometimes we will need to call finally() asynchronously because we are in a bad state and can't deal with re-entrancy issues. It might be good to guarantee that we always call finally() asynchronously, so that sink code can be sure that none of its own code is executing synchronously. On the other hand, it may be sufficient to guarantee that none of the sink methods are on the stack. Everything applies the same to ReadableStream and TransformStream. WritableStream is just what's on my mind right now. |
Do thrown errors/rejections from the underlying source/sink get wrapped in a |
For ReadableStreams maybe |
These days I'm leaning towards providing no parameters to It means that if your stream owns a resource that can only be disposed of once, you'll have to track that yourself in your source/sink implementation, but I suspect people would prefer to do that for robustness anyway. I mean something like const source = {
start() {
this._need_dispose = true;
this._resource = AcquireResource();
},
cancel() {
DisposeResource(this._resource);
this._need_dispose = false;
},
finally() {
if (this._need_dispose) {
DisposeResource(this._resource);
}
} This is not actually a good example because you could just always leave the disposal until Anyway, if *Subject to writing many, many, many wpts. |
Discussion at #617 (comment) #617 (comment) #620 (comment) and #628 (comment) mentioned the need for adding a
finally()
method to underlyingSink (and underlyingSource?) at some point in the future.It sounds like the ideas for
finally
areabort
,close
, (andcancel
andflush
?) etc, are called (after their returned promises fulfill?)Proposed arguments were
finally(why, reason)
, wherewhy
is e.g. the string 'close' or 'abort', but what about all the other causes forfinally
to be called? What would 'why' be for an invalid queueing strategy return value causing aRangeError
?Should it stay as two arguments like that, or one object analogous to an IteratorResult?
The text was updated successfully, but these errors were encountered: