Skip to content

bug: 4.5 breaks browser bundling of auth / runs.subscribeToRun (AsyncLocalStorage via sdk-scope-storage) #4711

Description

@marcnajera

Provide environment information

System:
OS: macOS 26.5.1
CPU: (8) arm64 Apple M3
Memory: 118.22 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.13.1 - /Users/marc/.nvm/versions/node/v24.13.1/bin/node
Yarn: 1.22.22 - /Users/marc/.nvm/versions/node/v24.13.1/bin/yarn
npm: 11.8.0 - /Users/marc/.nvm/versions/node/v24.13.1/bin/npm
pnpm: 11.10.0 - /Users/marc/.nvm/versions/node/v24.13.1/bin/pnpm
Deno: 2.9.5 - /opt/homebrew/bin/deno

Describe the bug

Importing auth from @trigger.dev/sdk in a Vite client bundle (SvelteKit in our case) fails after upgrading 4.4.6 → 4.5.11. Same frontend code that followed the documented Realtime pattern:

import { runs, auth } from "@trigger.dev/sdk";
auth.configure({ accessToken: publicToken });
for await (const run of runs.subscribeToRun(runId)) { ... }

App build error

"AsyncLocalStorage" is not exported by "__vite-browser-external"
imported by @trigger.dev/core/.../sdkScope/storage-node.js

Likely cause

In 4.5, auth.js gained a side-effect import:

import "@trigger.dev/core/v3/sdk-scope-storage";

That export only points at storage-node.ts (import { AsyncLocalStorage } from "node:async_hooks"). There is no browser/default stub. Vite tries to put it in the client graph and Rollup fails.

4.4.6 auth.js did not have this import, so the same client usage built fine.

This looks unintentional: runWithConfig already documents a browser/edge fallback when ALS isn’t installed, but the side-effect import crashes at bundle time, so that fallback never runs. The 4.5.0 changelog doesn’t list this as a breaking change.

Expected

auth.configure + runs.subscribeToRun keep working in a browser bundle, as in 4.4 and as the Realtime frontend examples show.

Reproduction repo

To reproduce

Running vite build

Additional information

No response

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