nextjs - ✅(Solved) Fix Next.js 16.1.1: DevTools causes infinite console error loop [2 pull requests, 5 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#88234Fetched 2026-04-08 02:05:18
View on GitHub
Comments
5
Participants
5
Timeline
15
Reactions
1
Author
Timeline (top)
commented ×5labeled ×3cross-referenced ×2referenced ×2

Error Message

TypeError: interop_require_wildcard. is not a function at eval (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/next-devtools/...) [INFO] Download the React DevTools... [LOG] [HMR] connected

Fix Action

Fixed

PR fix notes

PR #88241: fix(devtools): prevent infinite console error loop

Description (problem / solution / changelog)

Summary

Fixes #88234

This PR adds a re-entrancy guard to prevent the infinite console error loop that occurs in Next.js 16.1.1 when DevTools are open.

Problem

When DevTools are open in the browser, the console floods with TypeError: _interop_require_wildcard._ is not a function errors at approximately 3 errors/second. This makes development unusable.

Root Cause: When handleConsoleError() or forwardErrorLog() in the patched console.error throws an error, it triggers another console.error call, which is also patched, creating infinite recursion.

Solution

Add a simple re-entrancy guard pattern to intercept-console-error.ts:

let isHandlingError = false

// Inside patched console.error:
if (isHandlingError) {
  originConsoleError.apply(window.console, args)
  return
}

isHandlingError = true
try {
  // ... existing implementation
} catch (e) {
  originConsoleError.apply(window.console, args)
} finally {
  isHandlingError = false
}

Changes

  • packages/next/src/next-devtools/userspace/app/errors/intercept-console-error.ts: Added re-entrancy guard (~15 lines)
  • test/e2e/devtools-error-loop/: New e2e test suite with 3 tests

Test Plan

  • No infinite error loop when DevTools are open
  • Legitimate errors still display correctly (exactly once)
  • Fix remains stable through page reloads
  • TypeScript types pass
  • ESLint passes

How to Test

  1. Clone this branch
  2. pnpm install && pnpm build
  3. Create a Next.js app with npx create-next-app@canary
  4. Link the built Next.js: npm link /path/to/next.js/packages/next
  5. Run npm run dev and open browser DevTools
  6. Observe: no error flooding in console

Or run the e2e tests:

pnpm test-dev-turbo test/e2e/devtools-error-loop/devtools-error-loop.test.ts

Changed files

  • packages/next/src/next-devtools/userspace/app/errors/intercept-console-error.ts (modified, +40/-21)
  • test/e2e/devtools-error-loop/app/error-page/page.tsx (added, +23/-0)
  • test/e2e/devtools-error-loop/app/layout.tsx (added, +11/-0)
  • test/e2e/devtools-error-loop/app/page.tsx (added, +11/-0)
  • test/e2e/devtools-error-loop/devtools-error-loop.test.ts (added, +109/-0)
  • test/e2e/devtools-error-loop/next.config.js (added, +1/-0)

PR #88418: test: add regression test for console.error infinite loop

Description (problem / solution / changelog)

What?

Adds a regression test suite for the console.error infinite loop bug reported in #88234.

Why?

Issue #88234 reports that Next.js DevTools can cause an infinite console error loop when an internal error occurs in the intercept-console-error.js handler. This test suite helps ensure the console.error handling doesn't cause infinite loops.

How?

Added a new test suite at test/development/app-dir/console-error-loop/ with 6 test cases:

  1. Internal error handling - Tests behavior when console.error handler throws internally
  2. Basic error logging - Tests single console.error calls don't loop
  3. Non-Error objects - Tests handling of strings, objects, null/undefined args
  4. Rapid consecutive errors - Tests 10 rapid console.errors stay bounded
  5. Suspense errors - Tests console.error during React Suspense
  6. DevTools handler - Tests actual Next.js DevTools handler with complex/malformed args

The tests detect infinite loops by counting console.error invocations and failing if the count exceeds reasonable bounds.

Fixes #88234

Changed files

  • test/development/app-dir/console-error-loop/app/devtools-error/page.tsx (added, +84/-0)
  • test/development/app-dir/console-error-loop/app/internal-error/page.tsx (added, +71/-0)
  • test/development/app-dir/console-error-loop/app/layout.tsx (added, +12/-0)
  • test/development/app-dir/console-error-loop/app/non-error-object/page.tsx (added, +45/-0)
  • test/development/app-dir/console-error-loop/app/page.tsx (added, +34/-0)
  • test/development/app-dir/console-error-loop/app/rapid-errors/page.tsx (added, +37/-0)
  • test/development/app-dir/console-error-loop/app/suspense-error/page.tsx (added, +20/-0)
  • test/development/app-dir/console-error-loop/console-error-loop.test.ts (added, +170/-0)
  • test/development/app-dir/console-error-loop/next.config.js (added, +5/-0)

Code Example

TypeError: _interop_require_wildcard._ is not a function
    at eval (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/next-devtools/...)
[INFO] Download the React DevTools...
[LOG] [HMR] connected

---

Operating System:
  Platform: linux
  Arch: x64
  Version: Linux 6.6.87.2-microsoft-standard-WSL2

Binaries:
  Node: 20.x
  npm: 10.x

Relevant Packages:
  next: 16.1.1
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.9.3

---

TypeError: _interop_require_wildcard._ is not a function
    at eval (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/next-devtools/userspace/app/errors/intercept-console-error.js)
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/hooperits/nextjs-16-devtools-loop-bug

To Reproduce

  1. Clone the reproduction repository: git clone https://github.com/hooperits/nextjs-16-devtools-loop-bug
  2. Run npm install
  3. Run npm run dev
  4. Open http://localhost:3000 in browser
  5. Open browser DevTools console
  6. Observe infinite error loop repeating ~3x per second:
TypeError: _interop_require_wildcard._ is not a function
    at eval (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/next-devtools/...)
[INFO] Download the React DevTools...
[LOG] [HMR] connected

Current vs. Expected behavior

Current behavior:

  • DevTools internal errors cause an infinite console error loop
  • The loop happens even on pages WITHOUT application errors
  • Console becomes unusable due to spam (~3 errors per second)
  • Significant performance overhead from infinite logging
  • The error originates from next-devtools/userspace/app/errors/intercept-console-error.js

Expected behavior:

  • Console errors should only be logged once
  • DevTools internal errors should not leak to user console
  • No infinite loops in the console

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: Linux 6.6.87.2-microsoft-standard-WSL2

Binaries:
  Node: 20.x
  npm: 10.x

Relevant Packages:
  next: 16.1.1
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.9.3

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

Runtime, Error Overlay

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

next dev (local)

Additional context

Things that DON'T fix it:

  • devIndicators: false in next.config.mjs (only hides visual indicator)
  • NEXT_DEVTOOLS_DISABLED=true env var (not recognized)

Related closed issues:

  • #74321 - Same issue in 15.1.x, closed as invalid (missing repro)
  • #74817 - Similar issue, closed as NOT_PLANNED (couldn't reproduce)

Both were closed without resolution. This issue persists in Next.js 16.1.1.

Stack trace origin:

The error originates in Next.js DevTools internal code:

TypeError: _interop_require_wildcard._ is not a function
    at eval (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/next-devtools/userspace/app/errors/intercept-console-error.js)

Impact:

  • Console becomes unusable for debugging
  • Significant performance overhead from infinite logging

extent analysis

TL;DR

Disable Next.js DevTools by setting NEXT_DEVTOOLS_DISABLED=true as an environment variable in the next.config.mjs file or in the command line before running npm run dev, although the issue states this doesn't work, it's worth trying alternative methods to set this variable.

Guidance

  1. Verify Environment Variable Setting: Ensure that the NEXT_DEVTOOLS_DISABLED=true environment variable is correctly set before running npm run dev. This can be done by adding it to the next.config.mjs file or by prefixing the command to run the development server, e.g., NEXT_DEVTOOLS_DISABLED=true npm run dev.
  2. Check for Alternative Configurations: Look into the Next.js documentation for any alternative configurations or flags that can disable DevTools or prevent the infinite error loop.
  3. Inspect intercept-console-error.js: Investigate the intercept-console-error.js file in the Next.js DevTools code to understand the cause of the _interop_require_wildcard._ is not a function error and see if there's a possible fix or workaround.
  4. Test with Different Next.js Versions: Try reproducing the issue with different versions of Next.js to see if it's a regression or a persistent problem.

Example

No specific code example is provided due to the lack of direct code references in the issue that could be modified to fix the problem.

Notes

The provided NEXT_DEVTOOLS_DISABLED=true environment variable does not seem to work as expected according to the issue description. Therefore, finding an alternative method to disable Next.js DevTools or to mitigate the infinite error loop is necessary.

Recommendation

Apply a workaround by attempting to disable Next.js DevTools through alternative methods since the standard approach does not work as expected. This could involve modifying the next.config.mjs file or using different environment variable settings.

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 Next.js 16.1.1: DevTools causes infinite console error loop [2 pull requests, 5 comments, 5 participants]