Skip to content

bundle option breaks handler resolution in dev mode #6253

Open

Description

@wujekbogdan

Use Case

I use a custom build pipeline (tsdown/rolldown) instead of SST's built-in esbuild because my project includes native binaries that require special bundling treatment (externals, copy steps). The build outputs to a dist/ directory which I reference via the bundle option.

This works perfectly with sst deploy, but breaks in sst dev.

Configuration

new sst.aws.Function("MyApi", {
  bundle: "./dist",
  handler: "lambda.handler",
});

Error

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at Object.pathToFileURL (node:url:1024:3)
    at .sst/platform/dist/nodejs-runtime/index.js:33:24

Cause

SST's dev mode nodejs-runtime tries to resolve the handler path using logic that expects source files relative to the project root. When bundle is provided, this resolution fails and returns undefined, which then crashes pathToFileURL().

Deploy mode works because it just zips the bundle directory without path resolution.

Workaround

new sst.aws.Function("MyApi", {
  ...($dev
    ? { handler: "./src/lambda.handler" }
    : { bundle: "./dist", handler: "lambda.handler" }),
});

Suggested Fix

When bundle is set, resolve handler paths relative to the bundle directory, not the project root.

Activity

  1. rafael-lua commented on Feb 21, 2026

    @rafael-lua

    Just leaving a +1 here. I prefer in general have control of bundling pipeline and use other tools than esbuild (such as tsdown).

    It was also confusing on what even was the issue, so I'm happy we have at least a workaround (ty @wujekbogdan ).

  2. artem-simutin commented on Apr 10, 2026

    @artem-simutin

    Same here, face the same issue by bundling Nest.js standalone application by using Webpack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions