Skip to content

fix(app-server): avoid blocking reconnect cleanup - #466

Merged
shiny-code-bot merged 1 commit into
mainfrom
code/rapid-relaunch-reconnect-464
Jul 24, 2026
Merged

fix(app-server): avoid blocking reconnect cleanup#466
shiny-code-bot merged 1 commit into
mainfrom
code/rapid-relaunch-reconnect-464

Conversation

@cbusillo

Copy link
Copy Markdown
Owner

Why

Rapid desktop quit/relaunch cycles could establish a replacement websocket while the app-server's single transport event loop was still synchronously draining RPCs from the disconnected client. In the reproduced failure, an old plugin/list remained active long enough for the replacement client's initialize handshake to exceed the desktop's 30-second deadline.

What changed

  • Close the disconnected client's RPC gate immediately so queued work cannot start.
  • Remove the dead connection from outgoing and thread-routing state before waiting for active RPCs.
  • Run RPC draining and connection-scoped resource cleanup in tracked background tasks, while preserving graceful drain and forced-shutdown abort behavior.
  • Add cleanup lifecycle logging and focused gate/cleanup task tests.
  • Add a deterministic websocket regression that holds plugin/list, disconnects the first client, proves a replacement client initializes before the old RPC is released, and then verifies cleanup completion.

Validation

  • just test -p codex-app-server connection_handling_websocket
  • just test -p codex-app-server connection_cleanup
  • just test -p codex-app-server connection_rpc_gate
  • just test -p codex-app-server command_exec_process_ids_are_connection_scoped_and_disconnect_terminates_process
  • just fix -p codex-app-server
  • Signed macOS engine canary: five clean quit/relaunch cycles and five immediate relaunch cycles all initialized over websocket against the same supervised engine PID, with no stdio fallback.

The full codex-app-server suite completed 888/896 tests; the eight failures were in unrelated existing command exec, remote store, thread history/rollback, turn-start, and web-search tests.

Refs #464

@cbusillo cbusillo added the code-reviewed Completed required multi-agent code review label Jul 24, 2026
@shiny-code-bot
shiny-code-bot merged commit aa1c1d5 into main Jul 24, 2026
10 checks passed
@shiny-code-bot
shiny-code-bot deleted the code/rapid-relaunch-reconnect-464 branch July 24, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-reviewed Completed required multi-agent code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants