nextjs - ✅(Solved) Fix Turbopack enabled apps fail to hydrate with a JS runtime error on Pale Moon browser [1 pull requests, 6 comments, 5 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#91448Fetched 2026-04-08 02:01:58
View on GitHub
Comments
6
Participants
5
Timeline
18
Reactions
0
Author
Assignees
Timeline (top)
commented ×6mentioned ×4subscribed ×4assigned ×1

Error Message

Error: Invariant: Expected document.currentScript to be a <script> element. Received null instead. This is a bug in Next.js.

Root Cause

Expected the app to hydrate without errors. But the app doesn't hydrated because of the turbopack runtime error:

Fix Action

Fixed

PR fix notes

PR #91452: fix : assetPrefix detection when document.currentScript is null

Description (problem / solution / changelog)

What?

  • Fix asset prefix detection when document.currentScript is null in the browser.

Why?

  • Turbopack apps failed to hydrate on Pale Moon because getAssetPrefix threw when document.currentScript was null.

How?

  • Fallback to the last <script> whose src contains /_next/ when document.currentScript is not an HTMLScriptElement, keeping existing invariant checks and asset prefix parsing.

fix : #91448

Changed files

  • packages/next/src/client/asset-prefix.ts (modified, +8/-1)

Code Example

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
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/meltuhamy/nextjspalemoonrepro

To Reproduce

  1. Open any turbopack nextjs app in Palemoon (e.g. https://nextjs.org/ )
  2. Observe whether the app hydrates and has any errors

Current vs. Expected behavior

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.

Provide environment information

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

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next build (local), next start (local), next dev (local), Vercel (Deployed), Other (Deployed)

Additional context

  • When turbopack is turned off, the issue disappears.
  • Investigating the error, it seems that the turbopack runtime relies on document.currentScript being not null in Promise.then callbacks.

extent analysis

TL;DR

The issue can be mitigated by disabling Turbopack or using a different browser, as the error is specific to Palemoon and Turbopack.

Guidance

  • The error message indicates that document.currentScript is null, which is expected to be a <script> element, suggesting a compatibility issue between Turbopack and Palemoon.
  • To verify the issue, try disabling Turbopack and check if the app hydrates without errors.
  • Investigate alternative browsers to see if the issue is specific to Palemoon.
  • Consider filing an issue with the Next.js or Turbopack teams, as the error message suggests that this is a bug in Next.js.

Example

No code snippet is provided, as the issue is related to a specific browser and build configuration.

Notes

The issue seems to be specific to the combination of Palemoon, Turbopack, and Next.js. Disabling Turbopack or using a different browser may be a temporary workaround.

Recommendation

Apply workaround: Disable Turbopack until the issue is resolved by the Next.js or Turbopack teams, as it is a known bug.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix Turbopack enabled apps fail to hydrate with a JS runtime error on Pale Moon browser [1 pull requests, 6 comments, 5 participants]