Commit 2796e9f
feat(ws): handle shutdown message for graceful destroy (#30)
Adds a new protocol.MessageTypeShutdown and a matching Handler.handleShutdown
so Safari can cleanly tear down a cloud sandbox's runner without waiting
on the 5s force-unregister timeout.
Flow when CloudManager.disconnectRunner sends a shutdown message:
1. Handler cancels all in-flight tasks via CancelAllTasks.
2. Waits up to 2s for in-flight tool results to flush via WaitForTasks —
well inside Safari's 5s force-unregister window.
3. Closes the WebSocket client, which sets c.closed so RunWithReconnect
returns nil instead of entering the reconnect loop.
Before this change, every cloud sandbox destroy hit the 5s timeout because
the runner silently ignored the shutdown message and stayed in its
reconnect loop until the server-side unregister finally fired.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 4089f6a commit 2796e9f
2 files changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
91 | 110 | | |
92 | 111 | | |
93 | 112 | | |
| |||
0 commit comments