Skip to content

persist WASIp3 HTTP handler until response body is drained#3454

Merged
dicej merged 1 commit intospinframework:mainfrom
dicej:drain-p3-response-bodies
Apr 9, 2026
Merged

persist WASIp3 HTTP handler until response body is drained#3454
dicej merged 1 commit intospinframework:mainfrom
dicej:drain-p3-response-bodies

Conversation

@dicej
Copy link
Copy Markdown
Contributor

@dicej dicej commented Apr 9, 2026

Prior to Wasmtime 43, we used the TaskExit return value from call_handle to wait for the task to complete after it had returned a value. However, that has been removed, so now the only way we know it's safe to exit the task passed to ProxyHandler::spawn is to attach a oneshot::Sender to the response body which will be notified when the body is dropped. We then await the corresponding oneshot::Receiver, at which point we know the guest has finished sending the response body.

This also adds a test to cover the case.

Finally, since Wasmtime 43.0.1 was released with important security fixes, I updated that as well.

Prior to Wasmtime 43, we used the `TaskExit` return value from `call_handle` to
wait for the task to complete after it had returned a value.  However, that has
been removed, so now the only way we know it's safe to exit the task passed to
`ProxyHandler::spawn` is to attach a `oneshot::Sender` to the response body
which will be notified when the body is dropped.  We then `await` the
corresponding `oneshot::Receiver`, at which point we know the guest has finished
sending the response body.

This also adds a test to cover the case.

Finally, since Wasmtime 43.0.1 was released with important security fixes, I
updated that as well.
Copy link
Copy Markdown
Collaborator

@itowlson itowlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried it with the SSE example and it worked great. Thank you!

@dicej dicej merged commit a794d6e into spinframework:main Apr 9, 2026
17 checks passed
@dicej dicej deleted the drain-p3-response-bodies branch April 9, 2026 20:28
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.

2 participants