Skip to content

Don't deliver cancellation to sync wait/poll/yield #546

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

Closed
wants to merge 1 commit into from

Conversation

lukewagner
Copy link
Member

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 the callback event loop or async waitable-set.{poll,wait} or yield (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 to yield or waitable-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 and waitable-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.

@lukewagner
Copy link
Member Author

Thinking about this some more, I realized that #548 was a better and more future-friendly solution to this problem, so closing this.

@lukewagner lukewagner closed this Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant