{"record":{"id":"db7b0c0efb0065fd","repo":"mastra-ai/mastra","slug":"worker-startup-state-during-startup-message","errorCode":null,"errorMessage":"Worker ${startup.state} during startup${'message' in startup && startup.message ? `: ${startup.message}` : ''}.","messagePattern":"Worker (.+?) during startup(.+?)` : ''\\}\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deployers/sandbox/src/worker.ts","lineNumber":373,"sourceCode":"    { label: 'create worker execution namespace' },\n  );\n  const stdinPath = await stageInput(config, paths, input);\n  const script = buildExecutionScript(config, paths, stdinPath);\n  await uploadFile(config.sandbox, paths.script, Buffer.from(script));\n  await runInSandbox(config.sandbox, `chmod 700 ${shellQuote(paths.script)}`);\n\n  try {\n    await launchExecution(config.sandbox, paths);\n  } catch (error) {\n    await writeFailedStatus(config.sandbox, paths, executionId, 'launch', error);\n    throw workerPhaseError('launch', error);\n  }\n\n  const resolvePaths = async () => paths;\n  const startup = await waitForStartup(config, executionId, resolvePaths);\n  if (startup.state === 'timed_out') await cancelExecution(config, executionId, resolvePaths, 'startup');\n  if (startup.state === 'failed' || startup.state === 'timed_out' || startup.state === 'provider_unavailable') {\n    throw new Error(\n      `Worker ${startup.state} during startup${'message' in startup && startup.message ? `: ${startup.message}` : ''}.`,\n    );\n  }\n\n  const info = await getInfoSafe(config.sandbox);\n  return deployment(config, executionId, info?.id ?? config.sandbox.id ?? 'unknown', info?.timeoutAt);\n}\n\nfunction execution(\n  config: WorkerExecutionConfig,\n  executionId: string,\n  sandboxId: string,\n  expiresAt?: Date,\n): SandboxWorkerExecution {\n  const resolvePaths = async () => executionPaths(await config.resolveRemoteDir(), executionId);\n  return {\n    sandboxId,\n    executionId,","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/deployers/sandbox/src/worker.ts#L355-L391","documentation":"This error is thrown by createExecution when a sandboxed worker fails to become healthy within the startup window. waitForStartup reports one of three fatal states — 'failed' (worker process exited or reported failure), 'timed_out' (worker did not signal readiness before the deadline), or 'provider_unavailable' (the sandbox provider API could not be reached) — and the library aborts, canceling the execution on timeout before throwing.","triggerScenarios":"Calling deployWorkerToSandbox (or the deployment flow) when the worker binary crashes during boot, the worker never writes its readiness/status file before the startup timeout elapses, or the sandbox provider API is unreachable/unauthorized during startup polling.","commonSituations":"Wrong startup command or entrypoint in the deploy config; missing env vars or files the worker needs at boot; input/output paths misresolved so the worker can't write status; slow cold-start exceeding the configured startup timeout; sandbox provider outage or expired credentials.","solutions":["Read the appended startup.message in the error — it usually contains the worker's own failure output (stderr); fix the underlying boot failure first.","If state is timed_out, increase the startup timeout in the deploy config or make the worker signal readiness earlier/faster.","If state is provider_unavailable, verify sandbox provider credentials, network access, and provider status.","Reproduce by running the worker command manually inside the sandbox and inspect logs; fix entrypoint, env, and path resolution.","Retry the deployment after fixing; the timed-out execution is canceled automatically so a new executionId is safe."],"exampleFix":"// before\nawait deployWorkerToSandbox({ sandbox, command: 'node dist/worker.js', startupTimeoutMs: 5000 });\n// after\nawait deployWorkerToSandbox({ sandbox, command: 'node dist/worker.js --ready-file /tmp/ready', startupTimeoutMs: 30000 });","handlingStrategy":"try-catch","validationCode":"// before deploying: verify provider reachability and config sanity\nif (!config.sandbox) throw new Error('sandbox provider not configured');\n// optionally ping provider API/health endpoint here","typeGuard":"function isFatalStartupState(s) { return s === 'failed' || s === 'timed_out' || s === 'provider_unavailable'; }","tryCatchPattern":"try {\n  const deployment = await deployWorkerToSandbox(config);\n} catch (e) {\n  if (/Worker (failed|timed_out|provider_unavailable) during startup/.test(e.message)) {\n    // inspect e.message for startup.message detail; adjust timeout/command, then retry with fresh executionId\n  } else throw e;\n}","preventionTips":["Make the worker write its readiness/status file as early as possible in boot.","Set a startup timeout that accounts for cold-start latency of the sandbox provider.","Smoke-test the worker command inside the sandbox image before automated deploys.","Monitor provider status/credentials; alert on provider_unavailable."],"tags":["sandbox","worker-startup","timeout","deployment"],"backgroundTag":"worker-startup-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}