Browser-specific hydration failure due to turbopack runtime assumptions.
The issue involves turbopack-enabled Next.js apps failing to hydrate on the Pale Moon browser due to a runtime error related to `document.currentScript`. The problem is specific to turbopack's assumptions about browser behavior. Fixing this requires understanding turbopack's runtime and browser compatibility nuances.
https://github.com/meltuhamy/nextjspalemoonrepro
Expected the app to hydrate without errors. But the app doesn't hydrated because of the turbopack runtime error:
Error: Invariant: Expected document.currentScript to be a <script> element. Received null instead. This is a bug in Next.js.
npx next info
/bin/sh: yarn: command not found
/bin/sh: pnpm: command not found
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:46 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6000
Available memory (MB): 65536
Available CPU cores: 10
Binaries:
Node: 25.6.1
npm: 11.9.0
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 16.2.0-canary.100 // Latest available version is detected (16.2.0-canary.100).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.3
Next.js Config:
output: N/A
Turbopack
next build (local), next start (local), next dev (local), Vercel (Deployed), Other (Deployed)
document.currentScript being not null in Promise.then callbacks.Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!