{"record":{"id":"986bdcd956c0ed49","repo":"Yeachan-Heo/oh-my-codex","slug":"detached-leader-interrupted-before-release-inte","errorCode":null,"errorMessage":"detached leader interrupted before release: ${interrupted}","messagePattern":"detached leader interrupted before release: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/index.ts","lineNumber":7095,"sourceCode":"      ...record,\n      ...(runtimeBinding ? {\n        tmux_internal_session_id: runtimeBinding.internalSessionId,\n        tmux_session_created: runtimeBinding.sessionCreated,\n        tmux_pane_pid: runtimeBinding.panePid,\n      } : {}),\n    });\n    if (payload.readyPath) {\n      writeDetachedLeaderReport(payload.readyPath, { version: 1, kind: \"ready\", nonce, sessionId: payload.sessionId, sessionName: payload.sessionName, paneId: pane, leaderPid: process.pid });\n      const releasePath = `${payload.readyPath}.release`;\n      const abortPath = `${payload.readyPath}.abort`;\n      const releaseDeadline = Date.now() + 30_000;\n      let interrupted: NodeJS.Signals | undefined;\n      const interrupt = (signal: NodeJS.Signals): void => { interrupted = signal; };\n      process.once(\"SIGINT\", () => interrupt(\"SIGINT\"));\n      process.once(\"SIGTERM\", () => interrupt(\"SIGTERM\"));\n      process.once(\"SIGHUP\", () => interrupt(\"SIGHUP\"));\n      while (true) {\n        if (interrupted) throw new Error(`detached leader interrupted before release: ${interrupted}`);\n        const release = readDetachedLeaderReport(releasePath);\n        if (release?.kind === \"release\" && release.nonce === nonce && release.sessionId === payload.sessionId && release.sessionName === payload.sessionName && release.leaderPid === process.pid) {\n          detachedHudProof = parseDetachedHudAuthorityProof(release.hud);\n          break;\n        }\n        const abort = readDetachedLeaderReport(abortPath);\n        if (abort?.kind === \"abort\" && abort.nonce === nonce && abort.sessionId === payload.sessionId && abort.sessionName === payload.sessionName && abort.leaderPid === process.pid) {\n          throw new Error(\"detached launch aborted before release\");\n        }\n        if (Date.now() >= releaseDeadline) throw new Error(\"detached leader release timed out\");\n        blockMs(20);\n      }\n      rmSync(releasePath, { force: true });\n      rmSync(abortPath, { force: true });\n    }\n    const child = spawn(process.platform === \"win32\" ? \"powershell.exe\" : \"/bin/sh\", process.platform === \"win32\" ? [\"-NoProfile\", \"-Command\", payload.codexCmd] : [\"-c\", payload.codexCmd], {\n      cwd: payload.cwd,\n      stdio: \"inherit\",","sourceCodeStart":7077,"sourceCodeEnd":7113,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L7077-L7113","documentation":"While the leader polls for the launcher's release report, it also watches for SIGINT/SIGTERM/SIGHUP; receiving any of these before release aborts with the signal name.","triggerScenarios":"The leader process receives Ctrl-C (SIGINT), kill (SIGTERM), or terminal hangup (SIGHUP) during the window between spawn and the release report file appearing.","commonSituations":"User presses Ctrl-C while the detached session is still bootstrapping, or a supervisor/tmux rule sends SIGHUP when the launching pane closes too early.","solutions":["Avoid sending interrupts while the detached launch is in progress; wait for the release confirmation","If cancellation is intended, use the CLI's abort mechanism (abort report) rather than signaling the leader","Increase launch timeout / fix slow bootstrap (e.g. tmux server cold start) so release arrives sooner"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"process.on('SIGINT', () => { /* defer: wait for release or use CLI abort */ });\ntry { await waitForRelease(); } catch (e) { if (/interrupted before release/.test((e as Error).message)) log('launch cancelled by signal — retry'); }","preventionTips":["Don't Ctrl-C during the launch window; use the CLI's abort command","Keep the launching terminal alive until release completes","Tune timeouts if bootstrap is slow on your machine"],"tags":["signals","detached-session","lifecycle"],"backgroundTag":"process-interrupted","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}