Skip to content

Vite + Bun: node:async_hooks error in browser with @tanstack/react-start-client #7151

@estatetrax

Description

@estatetrax

Which project does this relate to?

Router

Describe the bug

When using @tanstack/react-start-client, the browser throws:

Module "node:async_hooks" has been externalized for browser compatibility. Cannot access "node:async_hooks.AsyncLocalStorage" in client code.
Uncaught TypeError: import_node_async_hooks.AsyncLocalStorage is not a constructor

Your Example Website or App

localhost dev server

Steps to Reproduce the Bug or Issue

To Reproduce

Create a minimal Vite + Bun + React project.
Install latest @tanstack/start and @tanstack/react-start-client.
Create a minimal Vite + Bun + React project.
Install latest @tanstack/start and @tanstack/react-start-client.
Use this main.tsx:

import * as React from "react";
import { createRoot } from "react-dom/client";
import { StartClient } from "@tanstack/react-start-client";

const root = createRoot(document.getElementById("root")!);
root.render();

Start the Vite dev server and open in browser.

Expected behavior

The app should render without Node.js-only errors in the browser.

Screenshots or Videos

No response

Platform

OS: Ubuntu 24.04
Bun: latest
Vite: latest
@tanstack/start: 1.120.20
@tanstack/react-start-client: 1.166.30
Browser: Chrome 123

Additional context

Removing @tanstack/react-start-client eliminates the error.
@tanstack/react-query works fine.
The error appears even with no other dependencies or routes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions