Skip to content

[Start] v1.143.3 breaks both dev and production - Buffer is not defined + attachRouterServerSsrUtils is not defined #6204

@Andresuito

Description

@Andresuito

Which project does this relate to?

Start

Describe the bug

After upgrading to v1.143.3, TanStack Start has two critical bugs:

1. Development mode: ReferenceError: Buffer is not defined

  • Database client (postgres/pg) is bundled and executed in the browser
  • Occurs even though database is ONLY imported in .server.ts files
  • Error location: node_modules/postgres/src/bytes.js

2. Production mode: ReferenceError: attachRouterServerSsrUtils is not defined

  • Build succeeds but server crashes on startup
  • Error location: .output/server/chunks/_/server-FFq0J1Wz.mjs:594:3
  • Makes production deployment completely broken

Both issues suggest v1.143.3 has broken changes in:

  • Server/client code splitting (dev)
  • SSR utilities bundling (prod)

Your Example Website or App

none

Steps to Reproduce the Bug or Issue

  1. Create a TanStack Start project with database integration

  2. Install dependencies: bun add drizzle-orm postgres

  3. Create database client in src/lib/db/index.ts:

    import { drizzle } from "drizzle-orm/postgres-js";
    import postgres from "postgres";
    
    const connection = postgres(process.env.DATABASE_URL!);
    export const db = drizzle(connection);

Create server function in src/services/users.server.ts:

import { createServerFn } from "@tanstack/react-start";
import { db } from "@/lib/db";

export const getUsers = createServerFn({ method: "GET" })
.handler(async () => {
return await db.query.user.findMany();
});

Update package.json to v1.143.3:

"@tanstack/react-router": "^1.143.3",
"@tanstack/react-router-devtools": "^1.143.3",
"@tanstack/react-router-ssr-query": "^1.143.3",
"@tanstack/react-start": "^1.143.3",
"@tanstack/router-plugin": "^1.143.3"

Open browser at http://localhost:3000/
Check console → Error: ReferenceError: Buffer is not defined at node_modules/postgres/src/bytes.js
Note: Database is ONLY imported in .server.ts files but gets bundled in browser anyway.

Expected behavior

Server-only code (.server.ts files) and their dependencies (like postgres, pg, drizzle-orm) should be completely excluded from the client bundle and never execute in the browser.

Screenshots or Videos

buffer.error.mp4

Platform

  • Router / Start Version: 1.143.3
  • OS: macOS
  • Browser: Chrome
  • Bundler: Vite
  • Database: PostgreSQL with Drizzle ORM
  • Packages affected: Both postgres@3.4.7 and pg@8.x exhibit the same issue

Additional context

No response

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