Skip to content

bug: Bun runtime deploy fails with workspaces in package.json ("Workspace not found") #3272

@mouguu

Description

@mouguu

Description

When using runtime: 'bun' in trigger.config.ts, deploying a project that has "workspaces" in package.json fails with:

error: Workspace not found "frontend"
    at /app/package.json:50:5

The same project deploys successfully with runtime: 'node-22'.

Root Cause

The generated Containerfile copies only package.json before running bun install:

COPY --chown=bun:bun package.json ./          # Only root package.json
RUN bun install --production --no-save        # Bun validates workspaces strictly → ERROR
COPY --chown=bun:bun . ./                     # Workspace dirs arrive here, too late

npm/node tolerates missing workspace directories during install (warns but continues).
Bun strictly validates that all referenced workspaces exist and exits with an error if they don't.

Reproduction

  1. Have a package.json with workspaces:
{
  "workspaces": ["frontend"]
}
  1. Set runtime: 'bun' in trigger.config.ts:
export default defineConfig({
  project: 'my-project',
  runtime: 'bun',
});
  1. Run trigger deploy → build fails at the bun install step.

  2. Change to runtime: 'node-22' → build succeeds.

Environment

  • CLI version: 4.4.1
  • Cloud version: 4.4.3
  • Bun version in image: 1.3.3 (imbios/bun-node:1.3.3-20-slim)
  • OS: Ubuntu (GitHub Actions CI)

Suggested Fix

When runtime: 'bun', the Containerfile should handle workspaces before bun install. Some options:

  1. Copy workspace package.json files alongside the root package.json before install:

    COPY --chown=bun:bun package.json ./
    COPY --chown=bun:bun frontend/package.json ./frontend/
    RUN bun install --production --no-save
  2. Strip the workspaces field from package.json before running bun install:

    COPY --chown=bun:bun package.json ./
    RUN node -e "const p=JSON.parse(require('fs').readFileSync('package.json','utf8'));delete p.workspaces;require('fs').writeFileSync('package.json',JSON.stringify(p,null,2))"
    RUN bun install --production --no-save
  3. Allow build extensions to inject Containerfile instructions between COPY package.json and RUN bun install (currently addLayer only appends after the main build steps).

Workaround

Use runtime: 'node-22' instead of 'bun'. With processKeepAlive: true, warm starts are 100-300ms regardless of runtime, so the cold start difference is negligible for most workloads.

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