heygen-com/hyperframes · error · Error

[lambda deploy] handler ZIP build exited with code ${result.

Error message

[lambda deploy] handler ZIP build exited with code ${result.status ?? "unknown"}

What it means

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.

Source

Thrown at packages/cli/src/commands/lambda/deploy.ts:110

  console.log();
  console.log(c.success("Stack deployed."));
  console.log(`  ${c.dim("Bucket:")}         ${outputs.bucketName}`);
  console.log(`  ${c.dim("State machine:")}  ${outputs.stateMachineArn}`);
  console.log(`  ${c.dim("Function:")}       ${outputs.functionName}`);
  console.log(`  ${c.dim("State file:")}     ${resolve(statePath)}`);
  console.log();
  console.log(c.dim(`Render with: hyperframes lambda render <project-dir>`));
}

function buildHandlerZip(root: string): void {
  // bun run --cwd packages/aws-lambda build:zip
  const result = spawnSync(
    "bun",
    ["run", "--cwd", join(root, "packages", "aws-lambda"), "build:zip"],
    { stdio: "inherit" },
  );
  if (result.status !== 0) {
    throw new Error(
      `[lambda deploy] handler ZIP build exited with code ${result.status ?? "unknown"}`,
    );
  }
}

View on GitHub (pinned to c2996c8626)

Solutions

  1. Reproduce the failure directly: `bun run --cwd packages/aws-lambda build:zip` and read its output.
  2. Run `bun install` at the repo root to ensure workspace deps are present.
  3. Fix the TypeScript/build errors the build:zip script reports.
  4. Confirm `bun` is installed and on PATH (`bun --version`).

Example fix

# before — deploy fails building the ZIP
hyperframes lambda deploy
# diagnose
bun run --cwd packages/aws-lambda build:zip
# after — fix reported errors, then
hyperframes lambda deploy
Defensive patterns

Strategy: try-catch

Validate before calling

// Reproduce the build step in isolation before deploying
import { spawnSync } from "node:child_process";
function buildZipSucceeds(root: string): boolean {
  return spawnSync("bun", ["run", "--cwd", `${root}/packages/aws-lambda`, "build:zip"], { stdio: "inherit" }).status === 0;
}

Try / catch

try {
  await runDeploy({ skipBuild: false, /* ... */ });
} catch (err) {
  if (/handler ZIP build exited/.test((err as Error).message))) {
    // run `bun run --cwd packages/aws-lambda build:zip` manually, fix reported errors, retry
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12). Data as JSON: /api/errors/dc4cd9a7f4d4e4ad. Report an issue: GitHub.