{"record":{"id":"6553105e6d21ccd0","repo":"Yeachan-Heo/oh-my-codex","slug":"detached-post-launch-lifecycle-cleanup-failed","errorCode":null,"errorMessage":"detached post-launch lifecycle cleanup failed","messagePattern":"detached post-launch lifecycle cleanup failed","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"warning","filePath":"src/cli/index.ts","lineNumber":7442,"sourceCode":"  await strict(async () => {\n    const { notifyLifecycle } = await import(\"../notifications/index.js\");\n    await notifyLifecycle(\"session-end\", {\n      sessionId, projectPath: cwd, projectName: basename(cwd), reason: \"session_exit\",\n    });\n  });\n  await strict(async () => {\n    const { markOwnedTeamsLeaderSessionStopped } = await import(\"../team/state.js\");\n    await markOwnedTeamsLeaderSessionStopped(cwd, sessionId);\n  });\n  await strict(() => emitNativeHookEvent(cwd, \"session-end\", {\n    session_id: sessionId,\n    context: buildNativeHookBaseContext(cwd, sessionId, \"finished\", {\n      project_path: cwd, project_name: basename(cwd), reason: \"session_exit\", status: \"finished\",\n    }),\n  }));\n  await strict(() => cleanupRuntimeCodexHome(runtimeCodexHomeForCleanup, projectLocalCodexHomeForCleanup));\n  if (releaseMarkerPath) await strict(() => rm(releaseMarkerPath, { force: true }));\n  if (failures.length > 0) throw new AggregateError(failures, \"detached post-launch lifecycle cleanup failed\");\n}\n\nasync function emitNativeHookEvent(\n  cwd: string,\n  event: \"session-start\" | \"session-end\" | \"session-idle\" | \"turn-complete\",\n  opts: {\n    session_id?: string;\n    thread_id?: string;\n    turn_id?: string;\n    mode?: string;\n    context?: Record<string, unknown>;\n  } = {},\n): Promise<void> {\n  const payload = buildHookEvent(event, {\n    source: \"native\",\n    context: opts.context || {},\n    session_id: opts.session_id,\n    thread_id: opts.thread_id,","sourceCodeStart":7424,"sourceCodeEnd":7460,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L7424-L7460","documentation":"runDetachedSessionPostLaunch aggregates cleanup steps (native hook events, codex home cleanup, release marker removal); any strict-mode failures are collected and rethrown as an AggregateError with this message.","triggerScenarios":"One or more awaited strict() cleanup helpers reject — e.g. rm of the release marker fails with EPERM/EBUSY, or cleanupRuntimeCodexHome hits a filesystem error.","commonSituations":"Antivirus/lockers holding files on Windows, NFS stale handles, or permissions changed after the session ran (e.g. files created as root).","solutions":["Inspect errors of the AggregateError (err.errors) to see which cleanup step failed","Fix the filesystem issue (permissions, locks) and re-run the cleanup command","Delete the leftover runtime codex home / release marker manually if it is safe"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await runDetachedSessionPostLaunch(...); } catch (e) {\n  if (e instanceof AggregateError) for (const inner of e.errors) log.warn('cleanup partial failure:', inner.message);\n}","preventionTips":["Exclude run dirs from antivirus/sync lockers","Keep consistent ownership of session files","Run cleanup with the same user that launched"],"tags":["cleanup","aggregate-error","detached-session"],"backgroundTag":"cleanup-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}