Skip to content

Add task cancellation - #18

Open
asteurer wants to merge 3 commits into
bytecodealliance:mainfrom
asteurer:add-task-cancellation
Open

asteurer wants to merge 3 commits into
bytecodealliance:mainfrom
asteurer:add-task-cancellation

Conversation

@asteurer

@asteurer asteurer commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #17.

Summary

The issue above identified a bug where a panic occurs when a future is cancelled and then written to, when it should be an error. While working on this, I also identified issues with streams permanently blocking after cancellation and added a fix for that as well.

Call outs

There were a couple of ways that we could have handled cancellation. One was to change the futures/streams API to return errors that would report whether a task was cancelled, but decided against this because it would introduce a breaking change and be more tedious for developers to use. I instead chose to use runtime.Goexit() because it seems to offer the simplest solution; however, I'm open to discussing this further.

Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com>
Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com>
Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com>
@asteurer

asteurer commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@dicej When you get a chance, I'd appreciate another pair of eyes on this. If you'd like to try this out locally, I've drafted a PR with my changes to wit-bindgen: bytecodealliance/wit-bindgen#1779

This branch has not been deployed

No deployments
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.

Async export panics with todo when the caller cancels it

1 participant