{"record":{"id":"938b655f7571fcb2","repo":"Yeachan-Heo/oh-my-codex","slug":"bound-session-retained-close-failed-closeeviden","errorCode":null,"errorMessage":"bound session retained close failed: ${closeEvidence.error?.message ?? \"unknown error\"}","messagePattern":"bound session retained close failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/index.ts","lineNumber":7391,"sourceCode":"      context: buildNativeHookBaseContext(cwd, sessionId, normalizedEvent, {\n        project_path: cwd,\n        project_name: basename(cwd),\n        duration_ms: durationMs,\n        reason: \"session_exit\",\n        status: normalizedEvent === \"failed\" ? \"failed\" : \"finished\",\n        ...(process.exitCode !== undefined\n          ? { exit_code: process.exitCode }\n          : {}),\n        ...(errorSummary ? { error_summary: errorSummary } : {}),\n      }),\n    });\n  } catch (err) {\n    logCliOperationFailure(err);\n    // Non-fatal\n  }\n  const closeEvidence = await closeLaunchSessionBindingOnce(binding);\n  if (closeEvidence.status === \"failed\") {\n    throw new Error(`bound session retained close failed: ${closeEvidence.error?.message ?? \"unknown error\"}`);\n  }\n}\n\nexport async function runDetachedSessionPostLaunch(\n  cwd: string,\n  sessionId: string,\n  projectLocalCodexHomeForCleanup?: string,\n  runtimeCodexHomeForCleanup?: string,\n  releaseMarkerPath?: string,\n): Promise<void> {\n  // The detached child is intentionally unbound: it must never perform parent\n  // pointer finalization or cleanup after the release barrier. It still owns\n  // every non-pointer terminal lifecycle responsibility.\n  const failures: unknown[] = [];\n  const strict = async (operation: () => Promise<unknown>): Promise<void> => {\n    try { await operation(); } catch (error) { failures.push(error); }\n  };\n","sourceCodeStart":7373,"sourceCodeEnd":7409,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L7373-L7409","documentation":"During post-launch handling, closing the retained launch session binding (closeLaunchSessionBindingOnce) returned status 'failed', and the error message is surfaced (or 'unknown error' if absent).","triggerScenarios":"closeLaunchSessionBindingOnce fails on I/O (binding file removed/locked) or on a state comparison mismatch while finalizing the retained binding.","commonSituations":"Concurrent CLI invocations finalizing the same binding, or a partially corrupted binding file after a crash mid-write.","solutions":["Read the embedded error message to identify the underlying cause (usually a file or state issue)","Remove/repair the stale binding artifact for that session and re-run the close/cleanup command","Avoid running multiple cleanup commands against the same session simultaneously"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await finalize(); } catch (e) {\n  if ((e as Error).message.startsWith('bound session retained close failed')) { /* read embedded cause, clear stale binding, retry once */ }\n}","preventionTips":["Serialize cleanup commands per session","Back up binding files before manual edits","Report persistent close failures with the embedded message"],"tags":["cleanup","state-machine","binding"],"backgroundTag":"cleanup-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}