{"record":{"id":"dc4cd9a7f4d4e4ad","repo":"heygen-com/hyperframes","slug":"lambda-deploy-handler-zip-build-exited-with-code","errorCode":null,"errorMessage":"[lambda deploy] handler ZIP build exited with code ${result.status ?? \"unknown\"}","messagePattern":"\\[lambda deploy\\] handler ZIP build exited with code (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/lambda/deploy.ts","lineNumber":110,"sourceCode":"  console.log();\n  console.log(c.success(\"Stack deployed.\"));\n  console.log(`  ${c.dim(\"Bucket:\")}         ${outputs.bucketName}`);\n  console.log(`  ${c.dim(\"State machine:\")}  ${outputs.stateMachineArn}`);\n  console.log(`  ${c.dim(\"Function:\")}       ${outputs.functionName}`);\n  console.log(`  ${c.dim(\"State file:\")}     ${resolve(statePath)}`);\n  console.log();\n  console.log(c.dim(`Render with: hyperframes lambda render <project-dir>`));\n}\n\nfunction buildHandlerZip(root: string): void {\n  // bun run --cwd packages/aws-lambda build:zip\n  const result = spawnSync(\n    \"bun\",\n    [\"run\", \"--cwd\", join(root, \"packages\", \"aws-lambda\"), \"build:zip\"],\n    { stdio: \"inherit\" },\n  );\n  if (result.status !== 0) {\n    throw new Error(\n      `[lambda deploy] handler ZIP build exited with code ${result.status ?? \"unknown\"}`,\n    );\n  }\n}\n","sourceCodeStart":92,"sourceCodeEnd":115,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/cli/src/commands/lambda/deploy.ts#L92-L115","documentation":"Thrown by buildHandlerZip when the spawned `bun run --cwd packages/aws-lambda build:zip` process exits with a non-zero status. The deploy command shells out to bun to assemble the handler ZIP (it bundles the Lambda runtime + Chrome); a build failure — TypeScript error, missing dependency, bun not installed, build script itself erroring — surfaces here with the exit code rather than proceeding to deploy a broken ZIP.","triggerScenarios":"Running `hyperframes lambda deploy` (without --skip-build) when the aws-lambda package fails to build: a TS compile error in that package, a missing workspace dependency, bun not on PATH, or a bug in the build:zip script itself.","commonSituations":"Uncommitted TS errors in packages/aws-lambda; `bun install` not run / lockfile out of sync; bun not installed in the deploy environment; a broken local change to the build script.","solutions":["Reproduce the failure directly: `bun run --cwd packages/aws-lambda build:zip` and read its output.","Run `bun install` at the repo root to ensure workspace deps are present.","Fix the TypeScript/build errors the build:zip script reports.","Confirm `bun` is installed and on PATH (`bun --version`)."],"exampleFix":"# before — deploy fails building the ZIP\nhyperframes lambda deploy\n# diagnose\nbun run --cwd packages/aws-lambda build:zip\n# after — fix reported errors, then\nhyperframes lambda deploy","handlingStrategy":"try-catch","validationCode":"// Reproduce the build step in isolation before deploying\nimport { spawnSync } from \"node:child_process\";\nfunction buildZipSucceeds(root: string): boolean {\n  return spawnSync(\"bun\", [\"run\", \"--cwd\", `${root}/packages/aws-lambda`, \"build:zip\"], { stdio: \"inherit\" }).status === 0;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runDeploy({ skipBuild: false, /* ... */ });\n} catch (err) {\n  if (/handler ZIP build exited/.test((err as Error).message))) {\n    // run `bun run --cwd packages/aws-lambda build:zip` manually, fix reported errors, retry\n  }\n}","preventionTips":["Run `bun install` at the repo root before deploy so workspace deps resolve.","Keep packages/aws-lambda TypeScript-clean (tsc) between deploys.","Confirm `bun --version` works in the deploy environment."],"tags":["cli","lambda","deploy","build","bun","child-process"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}