{"record":{"id":"6b09cf4265481afd","repo":"paperclipai/paperclip","slug":"action-timed-out-result-stderr-trim","errorCode":null,"errorMessage":"${action} timed out: ${result.stderr.trim()}","messagePattern":"(.+?) timed out: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sandbox-providers/cloudflare/bridge-template/src/routes.ts","lineNumber":118,"sourceCode":"  },\n  command: string,\n  args: string[],\n  cwd = \"/\",\n) {\n  return await executeInSandbox({\n    sandbox,\n    command,\n    args,\n    cwd,\n    timeoutMs: options.timeoutMs,\n    sessionStrategy: options.sessionStrategy,\n    sessionId: options.sessionId,\n  });\n}\n\nfunction requireZeroExit(action: string, result: { exitCode: number | null; timedOut: boolean; stderr: string }) {\n  if (result.timedOut) {\n    throw new Error(`${action} timed out: ${result.stderr.trim()}`);\n  }\n  if (result.exitCode !== 0) {\n    throw new Error(\n      `${action} failed with exit code ${result.exitCode ?? \"null\"}${result.stderr.trim() ? `: ${result.stderr.trim()}` : \"\"}`,\n    );\n  }\n}\n\nasync function ensureWorkspace(\n  sandbox: CloudflareSandbox,\n  options: {\n    remoteCwd: string;\n    sessionStrategy: SessionStrategy;\n    sessionId: string;\n    timeoutMs: number;\n  },\n) {\n  const result = await execLeaseUtility(sandbox, options, \"mkdir\", [\"-p\", options.remoteCwd], \"/\");","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/sandbox-providers/cloudflare/bridge-template/src/routes.ts#L100-L136","documentation":"Thrown by the Cloudflare bridge's `requireZeroExit` (routes.ts:118) when a lease-utility command (mkdir workspace, write/verify sentinel) returns `timedOut: true`. The wrapper `executeInSandbox` converts SDK timeout errors into a result with `timedOut: true` and a stderr message, and `requireZeroExit` surfaces that as a timed-out action error with the stderr detail.","triggerScenarios":"During `/leases/acquire`, `/leases/resume`, or `/probe`, an internal setup command (`mkdir -p <remoteCwd>`, sentinel write/verify) exceeds the `timeoutMs` window configured for the request (default `DEFAULT_TIMEOUT_MS`). Slow/cold-starting sandboxes or a frozen filesystem make the SDK's exec timeout trip.","commonSituations":"Cloudflare sandbox cold start adds latency that pushes the first mkdir/sentinel past the default timeout; an overloaded Workers/edge environment; or the caller set a very low `timeoutMs`.","solutions":["Increase `timeoutMs` in the acquire/probe/resume request body to accommodate sandbox cold-start.","Retry the lease acquire/resume — cold-start latency is often transient on the second attempt.","If persistent, check Cloudflare sandbox service health and the bridge deployment region."],"exampleFix":"// before\n{ method: \"POST\", body: JSON.stringify({ environmentId, runId, timeoutMs: 5000 }) }\n// after\n{ method: \"POST\", body: JSON.stringify({ environmentId, runId, timeoutMs: 60000 }) }","handlingStrategy":"retry","validationCode":"// Choose a timeout that tolerates cold start before the request.\nfunction leaseTimeoutMs(attempt) {\n  const base = 30000;\n  return attempt === 0 ? base : base * (attempt + 1); // 30s, 60s, 90s\n}","typeGuard":null,"tryCatchPattern":"async function acquireWithRetry(client, body, attempts = 3) {\n  let lastErr;\n  for (let i = 0; i < attempts; i++) {\n    try {\n      return await client.acquireLease({ ...body, timeoutMs: leaseTimeoutMs(i) });\n    } catch (err) {\n      lastErr = err;\n      if (err instanceof Error && err.message.includes(\"timed out\")) continue;\n      throw err;\n    }\n  }\n  throw lastErr;\n}","preventionTips":["Set timeoutMs large enough for sandbox cold start (>= 30s).","Retry acquire/resume once or twice on timeout — cold start is transient.","Monitor bridge Worker/edge latency; warm leases with keepAlive."],"tags":["cloudflare","sandbox","timeout","lease","bridge"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}