GeezerVison is showing github.com — pm-dispatch(sessions): a failure between createSession and the claim PATCH orphans a live OpenCode session — task cancelled, 'launch FAILED' noted, session id recorded nowhere · Issue #3009 · developing-today/code
pm-dispatch(sessions): a failure between createSession and the claim PATCH orphans a live OpenCode session — task cancelled, 'launch FAILED' noted, session id recorded nowhere #3009DescriptionProblem
In pm-dispatch (pm-stack/dispatch/src/server.ts, main fbfd1454), launchSession creates the OpenCode session before the claim PATCH that first records its id — and any failure in between is handled as a plain launch failure: the queue task is cancelled and the issue is noted "launch FAILED", while the already-created session is left running with its id recorded nowhere.
Evidence
launchSession order (server.ts): opencode.createSession(...) at :105, sendPrompt(session.id, ...) at :111, queue.ensureWorker() at :117, then the claim patchTask(task.id, { status: "claimed", progress: { session_id: session.id, ... } }) at :119 — the claim PATCH is the first durable record of the session id anywhere.
- Any throw from :111, :117 or :119 propagates out of
launchSession. Both callers treat every throw the same: the wait: false continuation calls handleLaunchFailure at :233 and the wait: true path at :252.
handleLaunchFailure (src/launch_failure.ts) cancels the task and comments Dispatch launch FAILED and queue task #<id> was cancelled. Error: <msg> on the issue. It receives no session id (the session exists only in launchSession's local scope) and records none.
OpenCodeClient (src/opencode.ts) exposes only createSession (:52), sendPrompt (:69) and listSessions (:73) — there is no close/delete/abort call the failure path could use to unwind a created session even if it wanted to.
- The post-claim annotation step is guarded for exactly this hazard (server.ts, comment above the annotation try/catch: a failure there "must not reject the launch — callers cancel the task on a rejected launch (fix(pm-dispatch): wait:false launch failures leave the queue task queued and the issue unnoted #2901), which would orphan a live session"). The guard covers only the steps after the claim; the create→claim window has the same hazard unguarded.
Why it matters
Acceptance criteria
- On any
launchSession failure after createSession has succeeded, the session id is recorded somewhere durable and visible: at minimum in the cancellation reason / task last_error and in the issue failure note (i.e. handleLaunchFailure or its call sites learn the session id).
- Either the failure path explicitly closes the created session (a close/delete method added to
OpenCodeClient, failure of the close itself noted, not fatal), or the design's Rule 2 invariant text is corrected to name the create→claim window as a known exception with the recorded-id mitigation above.
- A test in
pm-stack/dispatch/test/ pins the behavior: stub createSession to succeed and sendPrompt (and separately the claim PATCH) to throw; assert the failure handling receives/records the session id (and closes the session, if that route is chosen).
- Existing dispatch tests still pass (
bun test in pm-stack/dispatch).
Found by new-issue-creator-code-a, run 2026-10-31; verified by direct read of server.ts, launch_failure.ts, opencode.ts on main fbfd1454 this run. Dedup: searched open+closed issues for pm-dispatch session/orphan/launch — #2660 (post-claim annotations, guarded on main), #2901 (cancellation parity), #2668 (design; asserts the invariant this issue gives a counterexample to). None covers the create→claim window. Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item effort/xsTrivial: expected under 30 minutes of work on Oct 31, 2026dezren39 commented on Oct 31, 2026 dezren39 commented on Nov 2, 2026
🤖 Agent note · picked up (resumed)
dezren39 commented on Nov 2, 2026
🤖 Agent note · parked — awaiting CI
dezren39 commented on Nov 2, 2026 dezren39 commented on Nov 2, 2026 🤖 Agent note · state: parked
- Agent: Lane C queue worker (repo-worker-code)
- Session / ID: queue task 5516
- Found via: fresh queue claim (resume; PR already open)
- Task: Shepherd PR fix(pm-dispatch): clean up orphaned launch sessions #4350 (orphaned OpenCode session record + close on dispatch launch failure) for pm-dispatch(sessions): a failure between createSession and the claim PATCH orphans a live OpenCode session — task cancelled, 'launch FAILED' noted, session id recorded nowhere #3009.
- State: PR fix(pm-dispatch): clean up orphaned launch sessions #4350 OPEN, non-draft, head 076822d (+193/−35, 4 files); Codex review on this head complete with no findings and there are no review threads; no hard-stop labels on pm-dispatch(sessions): a failure between createSession and the claim PATCH orphans a live OpenCode session — task cancelled, 'launch FAILED' noted, session id recorded nowhere #3009. CI runs 41441696886 (pm-stack tests) and 41441696871 (pm-aggregator tests) still queued since 2026-11-02T12:04Z.
- Resume: When both runs complete green, merge PR fix(pm-dispatch): clean up orphaned launch sessions #4350 and close pm-dispatch(sessions): a failure between createSession and the claim PATCH orphans a live OpenCode session — task cancelled, 'launch FAILED' noted, session id recorded nowhere #3009; if a run fails, inspect and fix forward on branch queue/5516-3009-orphaned-session.
- Links: pm-dispatch(sessions): a failure between createSession and the claim PATCH orphans a live OpenCode session — task cancelled, 'launch FAILED' noted, session id recorded nowhere #3009, PR fix(pm-dispatch): clean up orphaned launch sessions #4350
dezren39 commented on Nov 2, 2026 🤖 Agent note · done — PR #4350 merged
- Agent: queue worker (repo-worker-code), Lane E shift
- Session / ID: queue task 5516, completed 2026-11-02T14:16Z
- Done: PR fix(pm-dispatch): clean up orphaned launch sessions #4350 MERGED (merge commit dff881b); pm-dispatch(sessions): a failure between createSession and the claim PATCH orphans a live OpenCode session — task cancelled, 'launch FAILED' noted, session id recorded nowhere #3009 auto-closed. Orphaned OpenCode sessions created before a dispatch launch failure are now recorded and closed best-effort, with regressions for prompt and claim-patch failures.
- Evidence: prior lane checkpoints:
bun test test/launch_failure.test.ts 5 passed, full bun test 118 passed, git diff --check clean. Codex review on head 076822d: no findings, no review threads. PR CI checks (test, aggregator + projector) were still QUEUED after 2h+ in the runner backlog at merge; merged under the standing merge-authority rule.
- Links: pm-dispatch(sessions): a failure between createSession and the claim PATCH orphans a live OpenCode session — task cancelled, 'launch FAILED' noted, session id recorded nowhere #3009; PR fix(pm-dispatch): clean up orphaned launch sessions #4350; queue task 5516
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|