Don't deliver cancellation to sync wait/poll/yield #546
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, if a caller tries to cancel an async callee while the callee is in the middle of executing a synchronous call to
subtask.cancel
or{stream,future}.{,cancel-}{read,write}
, the synchronous call completes normally and the request-for-cancellation is recorded in the task's state, to be delivered at the next turn of thecallback
event loop orasync
waitable-set.{poll,wait}
oryield
(which are required to expect and handle "cancelled" as a result). The reason for this is that these synchronous calls may happen in the middle of some library/dependency that isn't aware of async or connected to the caller's async runtime and thus doesn't know what to do with being "cancelled", leading to the notification being dropped on the floor instead of propagated to the async runtime. However, synchronous calls toyield
orwaitable-set.{poll,wait}
may return cancellation (if the caller cancels). But it seems like these synchronous calls are in the same boat as the other synchronous calls and thus the "dropped on the floor" hazard is the same.To fix this, this PR changes synchronous
yield
andwaitable-set.{poll,wait}
to have the same non-cancellable behavior as the other synchronous calls mentioned above. The PR also adds a.wast
test for this new behavior.