anomalyco/sst · error · Error

result.errors.join("\n")

Error message

result.errors.join("\n")

What it means

buildHandler() invokes the embedded Go runtime via the "Runtime.Build" RPC, which returns an errors array for esbuild/bundling problems. If any errors are reported, they are joined and thrown as a single Error — this is the bundler failure message you see in your terminal.

Source

Thrown at platform/src/components/aws/function.ts:2105

      return Link.getInclude<Permission>("aws.permission", args.link);
    }

    function buildHandler() {
      return all([runtime, dev, isContainer]).apply(
        async ([runtime, dev, isContainer]) => {
          if (dev) {
            return resolveDevBridge();
          }

          const buildResult = buildInput.apply(async (input) => {
            const result = await rpc.call<{
              handler: string;
              out: string;
              errors: string[];
              sourcemaps: string[];
            }>("Runtime.Build", { ...input, isContainer });
            if (result.errors.length > 0) {
              throw new Error(result.errors.join("\n"));
            }
            if (args.hook?.postbuild) await args.hook.postbuild(result.out);
            return result;
          });

          return {
            handler: buildResult.handler,
            bundle: buildResult.out,
            sourcemaps: buildResult.sourcemaps,
          };

          function resolveDevBridge() {
            if (durable) {
              return {
                handler: "index.handler",
                bundle: path.join($cli.paths.platform, "dist", "nodejs-bridge"),
                sourcemaps: undefined,
              };

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Read the joined error lines above the throw — they contain the esbuild file/line diagnostics
  2. Install missing dependencies (bun install / npm install)
  3. Fix or remove the import path reported in the first error line
  4. Run `sst dev` locally to iterate on the bundle quickly

Example fix

// before (handler.ts)
import { helper } from "./helpr"; // typo
// after
import { helper } from "./helper";
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check imports resolve before build
import fs from "fs";
const entry = "src/index.ts";
if (!fs.existsSync(entry)) throw new Error(`Handler entry not found: ${entry}`);

Try / catch

try {
  const result = await fnHandlerBuild(input);
} catch (e) {
  const lines = (e as Error).message.split("\n");
  console.error("esbuild errors:", lines); // first line names file + position
  process.exit(1);
}

Prevention

When it happens

Trigger: Any bundling error: TypeScript type-independent syntax errors, unresolved imports, missing node_modules, bad loader configuration, or invalid entrypoints/handler paths passed to the esbuild build inside the runtime.

Common situations: Importing a package that isn't installed; typo'd relative import path; using Node APIs not available in the target; monorepo path alias not configured in build args.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/5b57ed5ce81cef48. Report an issue: GitHub.