feat(web): inline worktree setup rows and async setup scripts #11832
main fromrefs/pull/11832/head·merged by juliusmarminge View on GitHubShowing 18 changed files with 155 additions and 0 deletions (loading 15).
🟡 Medium project/ProjectSetupScriptRunner.ts:415
Defaulting async to true allows dispatchFromClient(finalTurnStartCommand) to fail before setupResult.completion is run, leaving the terminal listener and its captured state retained for the server lifetime. Effect.ensuring only unsubscribes when the completion effect runs; ensure cleanup on dispatch failure or avoid defaulting setup scripts to asynchronous execution.
Also found in 1 other location(s)
apps/server/src/ws.ts:1227
When an async setup script is launched but
dispatchFromClient(finalTurnStartCommand)subsequently fails, the returnedawaitCompletioneffect is never run because it is only forked after that dispatch succeeds.observeTerminalCompletiononly invokes itsunsubscribefinalizer whencompletionis run, so its callback remains permanently interminalEventListenerseven after thread-deletion closes the terminal. Each such failed bootstrap leaks a listener (and its captured state) for the lifetime of the server.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/project/ProjectSetupScriptRunner.ts around line 415:
Defaulting `async` to `true` allows `dispatchFromClient(finalTurnStartCommand)` to fail before `setupResult.completion` is run, leaving the terminal listener and its captured state retained for the server lifetime. `Effect.ensuring` only unsubscribes when the completion effect runs; ensure cleanup on dispatch failure or avoid defaulting setup scripts to asynchronous execution.
Also found in 1 other location(s):
- apps/server/src/ws.ts:1227 -- When an async setup script is launched but `dispatchFromClient(finalTurnStartCommand)` subsequently fails, the returned `awaitCompletion` effect is never run because it is only forked after that dispatch succeeds. `observeTerminalCompletion` only invokes its `unsubscribe` finalizer when `completion` is run, so its callback remains permanently in `terminalEventListeners` even after thread-deletion closes the terminal. Each such failed bootstrap leaks a listener (and its captured state) for the lifetime of the server.
Fixed in 625e6a099b: the completion effect is now forked as soon as the script starts, so the terminal listener is always consumed regardless of whether the turn dispatch succeeds. Sync scripts join that fiber before the turn; async scripts join it after the handoff to settle the snapshot.