Skip to content

Break WASIp3 HTTP server ownership cycle - #3704

Merged
fibonacci1729 merged 1 commit into
spinframework:mainfrom
carsonfarmer:codex/fix-wasip3-http-server-cycle
Sep 1, 2026
Merged

Break WASIp3 HTTP server ownership cycle#3704
fibonacci1729 merged 1 commit into
spinframework:mainfrom
carsonfarmer:codex/fix-wasip3-http-server-cycle

Conversation

@carsonfarmer

Copy link
Copy Markdown
Contributor

Fixes #3703.

The WASIp3 handler state stored a strong reference to HttpServer. The server also owns that handler state. After the first WASIp3 request, these references kept each other alive and prevented the server and its application state from being released.

This change stores a weak reference in the handler state. Spin upgrades it while it creates a new WASIp3 worker. If the server is already gone, worker creation returns an error.

The regression test sends two single-use WASIp3 requests. It then drops the in-process server and verifies that the server was released. The test failed on upstream main before the production change and passes with this change.

Active workers can still keep the server alive until they end. This change only removes the permanent server-to-handler-to-server reference cycle.

No dependencies or services were added.

Tests

  • make lint
  • make build
  • cargo test -p spin-trigger-http --no-fail-fast -- --nocapture
  • cargo test --test integration wasi_http_p3 -- --nocapture
  • cargo test --test integration wasip3_handler_does_not_retain_http_server -- --nocapture

Signed-off-by: carsonfarmer <carson.farmer@gmail.com>

Co-authored-by: Codex <noreply@openai.com>
@carsonfarmer
carsonfarmer force-pushed the codex/fix-wasip3-http-server-cycle branch from 77b1db7 to ea32a8e Compare August 31, 2026 22:17
@itowlson
itowlson requested review from dicej and lann August 31, 2026 22:36
@itowlson

Copy link
Copy Markdown
Collaborator

@carsonfarmer Thanks for the report and the PR. It looks good to my inexpert eye, but I've flagged a couple of knowledgeable folks for a review.

For our guidance, how urgent is this for you? And would you require it in a release, or do you pin to a SHA?

@carsonfarmer

Copy link
Copy Markdown
Contributor Author

I'm just pinning to sha, so no rush on this honestly.

@dicej dicej left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks so much for catching, fixing, and adding a test for this, @carsonfarmer!

@fibonacci1729
fibonacci1729 merged commit 0d7ccdb into spinframework:main Sep 1, 2026
17 checks passed
@carsonfarmer
carsonfarmer deleted the codex/fix-wasip3-http-server-cycle branch September 1, 2026 20:11
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.

WASIp3 handler keeps the HTTP server alive

4 participants