[GH-ISSUE #797] @clerk/nextjs causes segfault during client bundle (step 4/5) — Rolldown crash at 3774 modules #172

Closed
opened 2026-05-06 12:37:52 +02:00 by BreizhHardware · 2 comments

Originally created by @Shorebirdmgmt on GitHub (Apr 9, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/797

Description

vinext build segfaults during step 4/5 (client environment build) after successfully transforming 3774 modules. The crash occurs in Rolldown's chunk rendering phase — no JS error, no backtrace, just SIGSEGV (exit code 139).

Additionally, vinext check reports @clerk/nextjs as incompatible: "deep Next.js middleware integration not compatible."

Reproduction

Environment:

  • vinext 0.0.40
  • Vite 8.0.7
  • Rolldown 1.0.0-rc.13
  • Node.js v25.3.0
  • Linux (Fedora 43, x86_64)
  • 62GB RAM available

Project: Next.js 16 App Router monorepo with:

  • @clerk/nextjs v7.0.12 (auth provider + middleware)
  • @tailwindcss/vite v4
  • @cloudflare/vite-plugin
  • @vitejs/plugin-rsc
  • shadcn/ui component library (~3774 client modules)

Steps:

  1. npm install vinext @cloudflare/vite-plugin @tailwindcss/vite @vitejs/plugin-rsc
  2. Create vite.config.ts:
import { defineConfig } from "vite";
import vinext from "vinext";
import { cloudflare } from "@cloudflare/vite-plugin";
import tailwindcss from "@tailwindcss/vite";

export default defineConfig({
  plugins: [
    vinext(),
    tailwindcss(),
    cloudflare({
      viteEnvironment: { name: "rsc", childEnvironments: ["ssr"] },
    }),
  ],
});
  1. npx vinext build

Output:

vinext build  (Vite 8.0.7)

[1/5] analyze client references...
✓ 367 modules transformed. ✓ built in 555ms
[2/5] analyze server references...
✓ 456 modules transformed. ✓ built in 323ms
[3/5] build rsc environment...
✓ 374 modules transformed. ✓ built in 534ms
[4/5] build client environment...
✓ 3774 modules transformed.
Segmentation fault (core dumped)

What I've tried

  • Removed @clerk/nextjs from proxy.ts (replaced with no-op middleware) — still crashes. Not Clerk-specific.
  • Removed @tailwindcss/vite plugin — build fails on CSS but same crash pattern when CSS resolves.
  • Removed postcss.config.mjs — no effect.
  • Next.js 16.2.2 and 16.1.6 — same crash on both.
  • NODE_OPTIONS="--max-old-space-size=8192" — no effect (62GB RAM available, not a memory issue).
  • RUST_BACKTRACE=full — no backtrace output (native crash in Rolldown binary, not surfaced through Node).
  • Increased stack size--stack-size not allowed in NODE_OPTIONS.

Analysis

The segfault is deterministic — always at exactly 3774 modules, always during the chunk rendering phase after transformation completes. Steps 1-3 complete successfully every time. The crash is in Rolldown 1.0.0-rc.13's native code during the client bundle chunking step.

Two issues

  1. Segfault (critical): Rolldown crashes on medium-large client bundles (~3774 modules). This happens regardless of @clerk/nextjs — even with a no-op middleware.

  2. Clerk compatibility (feature request): vinext check flags @clerk/nextjs as "deep Next.js middleware integration not compatible." Clerk is one of the most popular auth providers for Next.js — supporting @clerk/nextjs would significantly expand vinext's adoption for B2B SaaS apps.

Expected behavior

vinext build should complete all 5 steps without crashing, producing a deployable Cloudflare Worker bundle.

Originally created by @Shorebirdmgmt on GitHub (Apr 9, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/797 ## Description `vinext build` segfaults during step 4/5 (client environment build) after successfully transforming 3774 modules. The crash occurs in Rolldown's chunk rendering phase — no JS error, no backtrace, just `SIGSEGV (exit code 139)`. Additionally, `vinext check` reports `@clerk/nextjs` as incompatible: "deep Next.js middleware integration not compatible." ## Reproduction **Environment:** - vinext 0.0.40 - Vite 8.0.7 - Rolldown 1.0.0-rc.13 - Node.js v25.3.0 - Linux (Fedora 43, x86_64) - 62GB RAM available **Project:** Next.js 16 App Router monorepo with: - `@clerk/nextjs` v7.0.12 (auth provider + middleware) - `@tailwindcss/vite` v4 - `@cloudflare/vite-plugin` - `@vitejs/plugin-rsc` - shadcn/ui component library (~3774 client modules) **Steps:** 1. `npm install vinext @cloudflare/vite-plugin @tailwindcss/vite @vitejs/plugin-rsc` 2. Create `vite.config.ts`: ```ts import { defineConfig } from "vite"; import vinext from "vinext"; import { cloudflare } from "@cloudflare/vite-plugin"; import tailwindcss from "@tailwindcss/vite"; export default defineConfig({ plugins: [ vinext(), tailwindcss(), cloudflare({ viteEnvironment: { name: "rsc", childEnvironments: ["ssr"] }, }), ], }); ``` 3. `npx vinext build` **Output:** ``` vinext build (Vite 8.0.7) [1/5] analyze client references... ✓ 367 modules transformed. ✓ built in 555ms [2/5] analyze server references... ✓ 456 modules transformed. ✓ built in 323ms [3/5] build rsc environment... ✓ 374 modules transformed. ✓ built in 534ms [4/5] build client environment... ✓ 3774 modules transformed. Segmentation fault (core dumped) ``` ## What I've tried - **Removed `@clerk/nextjs` from proxy.ts** (replaced with no-op middleware) — still crashes. Not Clerk-specific. - **Removed `@tailwindcss/vite` plugin** — build fails on CSS but same crash pattern when CSS resolves. - **Removed `postcss.config.mjs`** — no effect. - **Next.js 16.2.2 and 16.1.6** — same crash on both. - **`NODE_OPTIONS="--max-old-space-size=8192"`** — no effect (62GB RAM available, not a memory issue). - **`RUST_BACKTRACE=full`** — no backtrace output (native crash in Rolldown binary, not surfaced through Node). - **Increased stack size** — `--stack-size` not allowed in NODE_OPTIONS. ## Analysis The segfault is deterministic — always at exactly 3774 modules, always during the chunk rendering phase after transformation completes. Steps 1-3 complete successfully every time. The crash is in Rolldown 1.0.0-rc.13's native code during the client bundle chunking step. ## Two issues 1. **Segfault (critical):** Rolldown crashes on medium-large client bundles (~3774 modules). This happens regardless of `@clerk/nextjs` — even with a no-op middleware. 2. **Clerk compatibility (feature request):** `vinext check` flags `@clerk/nextjs` as "deep Next.js middleware integration not compatible." Clerk is one of the most popular auth providers for Next.js — supporting `@clerk/nextjs` would significantly expand vinext's adoption for B2B SaaS apps. ## Expected behavior `vinext build` should complete all 5 steps without crashing, producing a deployable Cloudflare Worker bundle.
Author
Owner

@Shorebirdmgmt commented on GitHub (Apr 9, 2026):

Root Cause Found

The segfault is caused by react-simple-maps (v3.0.0), not @clerk/nextjs or module count.

How we isolated it

Binary search through our dependency tree in a worktree:

  1. Removed @clerk/nextjs entirely — still crashes (3663 modules). Clerk adds ~111 modules but is NOT the cause.
  2. Minimal app (empty page, no imports) — builds (33 modules)
  3. Added @opsidian/ui barrel import — crashes (3583 modules)
  4. Tested individual UI components — builds up to 3152 modules
  5. Added WorldMap component (uses react-simple-maps) — crashes (3474 modules)
  6. Tested all D3 sub-dependencies individually (d3-geo, d3-zoom, d3-selection, topojson-client) — all build fine
  7. import { ComposableMap } from "react-simple-maps" alone — crashes (3461 modules)
  8. Externalized react-simple-maps via build.rollupOptions.externalbuilds (3355 modules)
  9. Full app with externalized react-simple-maps — builds (3355 modules)

Analysis

All D3 sub-dependencies work individually. The crash only occurs when Rolldown processes react-simple-maps' own ESM bundle (dist/index.es.js, 1053 lines) which re-exports and combines these dependencies. A specific code pattern in that file triggers a bug in Rolldown's Rust chunk rendering logic.

The crash happens after all modules are successfully transformed but during the native chunk rendering phase — SIGSEGV with no JS stack trace.

Workaround

// vite.config.ts
export default defineConfig({
  build: {
    rollupOptions: {
      external: ["react-simple-maps"],
    },
  },
});

Separate issue: @clerk/nextjs

vinext check correctly flags @clerk/nextjs as incompatible ("deep Next.js middleware integration not compatible"). This is a separate issue from the segfault — Clerk's middleware works fine in Next.js but vinext doesn't support the Next.js middleware internals that Clerk hooks into. Reporting this separately is probably better since it's a feature gap, not a crash.

<!-- gh-comment-id:4211158395 --> @Shorebirdmgmt commented on GitHub (Apr 9, 2026): ## Root Cause Found The segfault is caused by **`react-simple-maps`** (v3.0.0), not `@clerk/nextjs` or module count. ### How we isolated it Binary search through our dependency tree in a worktree: 1. Removed `@clerk/nextjs` entirely — **still crashes** (3663 modules). Clerk adds ~111 modules but is NOT the cause. 2. Minimal app (empty page, no imports) — **builds** (33 modules) 3. Added `@opsidian/ui` barrel import — **crashes** (3583 modules) 4. Tested individual UI components — **builds** up to 3152 modules 5. Added `WorldMap` component (uses `react-simple-maps`) — **crashes** (3474 modules) 6. Tested all D3 sub-dependencies individually (`d3-geo`, `d3-zoom`, `d3-selection`, `topojson-client`) — **all build fine** 7. `import { ComposableMap } from "react-simple-maps"` alone — **crashes** (3461 modules) 8. Externalized react-simple-maps via `build.rollupOptions.external` — **builds** (3355 modules) 9. Full app with externalized react-simple-maps — **builds** (3355 modules) ### Analysis All D3 sub-dependencies work individually. The crash only occurs when Rolldown processes `react-simple-maps`' own ESM bundle (`dist/index.es.js`, 1053 lines) which re-exports and combines these dependencies. A specific code pattern in that file triggers a bug in Rolldown's Rust chunk rendering logic. The crash happens after all modules are successfully transformed but during the native chunk rendering phase — SIGSEGV with no JS stack trace. ### Workaround ```ts // vite.config.ts export default defineConfig({ build: { rollupOptions: { external: ["react-simple-maps"], }, }, }); ``` ### Separate issue: @clerk/nextjs `vinext check` correctly flags `@clerk/nextjs` as incompatible ("deep Next.js middleware integration not compatible"). This is a **separate issue** from the segfault — Clerk's middleware works fine in Next.js but vinext doesn't support the Next.js middleware internals that Clerk hooks into. Reporting this separately is probably better since it's a feature gap, not a crash.
Author
Owner

@Shorebirdmgmt commented on GitHub (Apr 9, 2026):

Closing to split into two separate issues with proper root cause analysis.

<!-- gh-comment-id:4211162154 --> @Shorebirdmgmt commented on GitHub (Apr 9, 2026): Closing to split into two separate issues with proper root cause analysis.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#172
No description provided.