mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #797] @clerk/nextjs causes segfault during client bundle (step 4/5) — Rolldown crash at 3774 modules #172
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#172
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Shorebirdmgmt on GitHub (Apr 9, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/797
Description
vinext buildsegfaults 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, justSIGSEGV (exit code 139).Additionally,
vinext checkreports@clerk/nextjsas incompatible: "deep Next.js middleware integration not compatible."Reproduction
Environment:
Project: Next.js 16 App Router monorepo with:
@clerk/nextjsv7.0.12 (auth provider + middleware)@tailwindcss/vitev4@cloudflare/vite-plugin@vitejs/plugin-rscSteps:
npm install vinext @cloudflare/vite-plugin @tailwindcss/vite @vitejs/plugin-rscvite.config.ts:npx vinext buildOutput:
What I've tried
@clerk/nextjsfrom proxy.ts (replaced with no-op middleware) — still crashes. Not Clerk-specific.@tailwindcss/viteplugin — build fails on CSS but same crash pattern when CSS resolves.postcss.config.mjs— no effect.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).--stack-sizenot 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
Segfault (critical): Rolldown crashes on medium-large client bundles (~3774 modules). This happens regardless of
@clerk/nextjs— even with a no-op middleware.Clerk compatibility (feature request):
vinext checkflags@clerk/nextjsas "deep Next.js middleware integration not compatible." Clerk is one of the most popular auth providers for Next.js — supporting@clerk/nextjswould significantly expand vinext's adoption for B2B SaaS apps.Expected behavior
vinext buildshould complete all 5 steps without crashing, producing a deployable Cloudflare Worker bundle.@Shorebirdmgmt commented on GitHub (Apr 9, 2026):
Root Cause Found
The segfault is caused by
react-simple-maps(v3.0.0), not@clerk/nextjsor module count.How we isolated it
Binary search through our dependency tree in a worktree:
@clerk/nextjsentirely — still crashes (3663 modules). Clerk adds ~111 modules but is NOT the cause.@opsidian/uibarrel import — crashes (3583 modules)WorldMapcomponent (usesreact-simple-maps) — crashes (3474 modules)d3-geo,d3-zoom,d3-selection,topojson-client) — all build fineimport { ComposableMap } from "react-simple-maps"alone — crashes (3461 modules)build.rollupOptions.external— 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
Separate issue: @clerk/nextjs
vinext checkcorrectly flags@clerk/nextjsas 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.@Shorebirdmgmt commented on GitHub (Apr 9, 2026):
Closing to split into two separate issues with proper root cause analysis.