Closed machty closed 8 years ago
It's actually an open question how the promises returned from async functions play with cancelation. You seem to be assuming that there'd be an implicit "cancelation opportunity" inserted at every await
point, but in general people do not seem to be in favor of that idea.
I think we discussed this and reached at the conclusion the only reasonable thing was to allow await
in finally to block. https://github.com/tc39/ecmascript-asyncawait/issues/51
People are expected to be reasonable in their finally
clauses.
@benjamingr Now that I've seen the Stage 1 proposal, it definitely seems most consistent to allow await
in finally
to block since canceling a token won't actually stop execution until the next cancelIfRequested
; it seems to follow that await
within finally
would just be yet another way to expand the time between canceling the token and stopping execution.
I'm mostly posting this issue so that it might be considered in some future spec, though I think I already know what the right answer is:
If a promise returned from
foo()
is (somehow) canceled, are there any restrictions to further (and potentially indefinitely) prolonging the lifespan of the canceled promise byawait
ing within a finally block? I came across this case while working on ember-concurrency and didn't want to implement anything potential outside of the cancelable-async-await spec.