{"record":{"id":"fb9e7516962e6f78","repo":"stablyai/orca","slug":"codex-trust-grant-entry-exceeded-request-invocat","errorCode":null,"errorMessage":"codex trust-grant entry exceeded ${request.invocation.timeoutMs}ms session deadline","messagePattern":"codex trust-grant entry exceeded (.+?)ms session deadline","errorType":"exception","errorClass":"CodexAppServerTimeoutError","httpStatus":null,"severity":"error","filePath":"src/main/codex/codex-app-server-grant-bridge.ts","lineNumber":105,"sourceCode":"): CodexAppServerEntryResult {\n  const entryPath = options.entryPath ?? resolveCodexGrantEntryPath()\n  if (!entryPath) {\n    throw new Error('codex trust-grant entry bundle not found')\n  }\n  const spawned = spawnSync(options.nodeCommand ?? process.execPath, [entryPath], {\n    input: JSON.stringify(request),\n    encoding: 'utf8',\n    timeout:\n      request.invocation.timeoutMs + (options.timeoutMarginMs ?? GRANT_ENTRY_TIMEOUT_MARGIN_MS),\n    killSignal: 'SIGKILL',\n    maxBuffer: GRANT_ENTRY_MAX_BUFFER_BYTES,\n    windowsHide: true,\n    env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' }\n  })\n  if ((spawned.error as NodeJS.ErrnoException | undefined)?.code === 'ETIMEDOUT') {\n    // Why: spawnSync reports its own deadline through error.code before the\n    // signal field; preserve the typed timeout so cooldown diagnostics work.\n    throw new CodexAppServerTimeoutError(\n      `codex trust-grant entry exceeded ${request.invocation.timeoutMs}ms session deadline`\n    )\n  }\n  if (spawned.error) {\n    throw spawned.error\n  }\n  if (spawned.signal) {\n    throw new CodexAppServerTimeoutError(\n      `codex trust-grant entry killed by ${spawned.signal} after ${request.invocation.timeoutMs}ms deadline`\n    )\n  }\n  const lines = (spawned.stdout ?? '').split('\\n').filter((line) => line.trim().length > 0)\n  const lastLine = lines.at(-1)\n  let envelope: GrantEntryEnvelope | null = null\n  if (lastLine) {\n    try {\n      envelope = JSON.parse(lastLine) as GrantEntryEnvelope\n    } catch {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/codex/codex-app-server-grant-bridge.ts#L87-L123","documentation":"Thrown as CodexAppServerTimeoutError when spawnSync reports error.code === 'ETIMEDOUT'. The spawn timeout is request.invocation.timeoutMs plus a margin (GRANT_ENTRY_TIMEOUT_MARGIN_MS, 5s). The typed error preserves the session deadline for cooldown diagnostics. This means the grant entry child process did not complete within the allotted time.","triggerScenarios":"The ELECTRON_RUN_AS_NODE child process running the codex trust-grant session exceeded the spawnSync timeout. The codex app-server inside the entry hung, the network was slow during OAuth, or the session JSON-RPC stream stalled.","commonSituations":"Codex app-server is unresponsive or waiting on a network request that never completes. The OAuth flow inside the grant entry is waiting for user interaction that doesn't come. System under heavy load causing the child to be starved. DNS resolution hanging.","solutions":["Retry the trust-grant operation — transient hangs may resolve.","Check network connectivity to the codex/OAuth endpoints.","If the issue persists, increase request.invocation.timeoutMs if the caller controls it.","Check if codex CLI itself is functional: run the codex command manually outside Orca."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"import { CodexAppServerTimeoutError } from '@orca/main/codex/codex-app-server-client'\n\nfunction isGrantTimeout(error: unknown): error is CodexAppServerTimeoutError {\n  return error instanceof CodexAppServerTimeoutError\n}","tryCatchPattern":"try {\n  runCodexHookTrustGrantSessionSync(request)\n} catch (error) {\n  if (error instanceof CodexAppServerTimeoutError &&\n      error.message.includes('exceeded') &&\n      error.message.includes('session deadline')) {\n    // Retry with backoff; cooldown diagnostics available on the typed error\n  } else { throw error }\n}","preventionTips":["Set request.invocation.timeoutMs generously enough for OAuth round-trips.","Pre-check network connectivity to codex endpoints before launching grant sessions.","Implement exponential backoff for CodexAppServerTimeoutError retries."],"tags":["codex","grant-bridge","timeout","spawn-sync","process-management"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}