Skip to content

Release Bun.serve handler Strongs once the server is idle (native↔JS cycle leak) - #32086

Closed
alii wants to merge 14 commits into
mainfrom
ali/serve-deinit-fixture-retainer
Closed

Release Bun.serve handler Strongs once the server is idle (native↔JS cycle leak)#32086
alii wants to merge 14 commits into
mainfrom
ali/serve-deinit-fixture-retainer

Merge branch 'main' into ali/serve-deinit-fixture-retainer

384e4e9
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jun 11, 2026 in 23m 7s

Code review found 1 important issue

Found 5 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 0
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/runtime/server/server_body.rs:2251-2256 reload() after graceful stop with live websockets unprotects the active handler

Annotations

Check failure on line 2256 in src/runtime/server/server_body.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

reload() after graceful stop with live websockets unprotects the active handler

The comment here ("a stopped (idle) server can never invoke the handlers this reload just installed") is not true when `stop()` was graceful and websockets opened before the reload are still connected: the swap at line 2203 resets `active_connections` to 0 at the same address the live `ServerWebSocket` `BackRef`s point into, so `has_active_web_sockets()` reads the new zero counter and this `deinit_if_we_can()` unprotects the freshly installed handler while those sockets are still dispatching to