Skip to content

fix(studio): close() ends open connections so a restart with a browser tab open exits - #1192

Merged
LinuxDevil merged 1 commit into
mainfrom
fix/studio-shutdown-open-sockets
Nov 17, 2026
Merged

LinuxDevil merged 1 commit into
mainfrom
fix/studio-shutdown-open-sockets

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

After deploying alpha.127 (with #1191), docker stop on the live Studio took the full timeout and exited 137: Docker had to kill it.

Cause: Studio's close() ends with server.close(), which waits for every open connection. Every Studio tab holds a WebSocket (/agents/:id/stream) open forever, so with a browser open shutdown never finished. Reproduced locally: no socket → exit 0 in 6 ms; one open WebSocket → still running after 8 s.

Fix: track the server's sockets and destroy them after server.close() starts. All the graceful steps (passes, workspaces, MCP servers, observe reporters, collector) still run first.

Test: server/__tests__/shutdown.test.ts opens a WebSocket and asserts close() finishes. Fails before, passes after. Studio server suite: 138/138.

🤖 Generated with Claude Code

…r tab open exits instead of hanging

server.close() waits for every open connection, and a Studio tab holds a
WebSocket open forever, so SIGTERM hung until Docker killed the container
(exit 137 after the stop timeout) and agents never reported 'stopped'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@lousho-ai lousho-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving.

The PR fixes the Studio shutdown hang by tracking HTTP connection sockets and destroying them after server.close() begins, so that browser WebSockets don't prevent process exit. The test in shutdown.test.ts verifies the fix.

Follow-up: none.

@LinuxDevil
LinuxDevil merged commit 2242bbf into main Nov 17, 2026
6 checks passed
@LinuxDevil
LinuxDevil deleted the fix/studio-shutdown-open-sockets branch November 17, 2026 20:27
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.

1 participant