Prevent SessionEnd from killing shared Codex tasks#491
Open
liby wants to merge 1 commit into
Open
Conversation
SessionEnd treated the workspace broker as owned by the exiting Claude session, so it could terminate another session's active Codex task and leave the caller waiting forever after the transport disappeared. Let the broker reject shutdown while requests, streams, or other clients are active, then exit after five minutes of complete idleness so crashed sessions cannot leave it alive indefinitely. Bound shutdown RPCs to one second and only tear down resources after an accepted response. Race task completion against transport exit, and fall back to a direct client only for marked broker connection failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Claude
SessionEndhook previously requested shutdown of the workspacebroker whenever any session exited. When two Claude sessions used the same
workspace, ending one session could stop the broker serving another session's
active Codex task. That task then lost its app-server transport and remained
running without a result, while the ending hook could be cancelled waiting for
shutdown.
The broker now owns the shutdown decision:
broker/shutdownwhile another client, request, or stream is active.The hook bounds shutdown requests to one second and removes only the resources
captured from a broker that accepted shutdown. Task execution races completion
against transport exit so a disconnected worker records a failure instead of
waiting indefinitely. Broker initialization falls back to a direct client only
for errors marked as broker transport failures.
Related to #490, which independently addresses orphaned brokers and the
shutdown connection race. This change also covers cross-session
SessionEndownership, bounded shutdown responses, stale broker reuse, and task failure on
transport loss.
Validation
npm run buildnpm run check-versiongit diff --check