nextjs - ✅(Solved) Fix NoFallbackError logged to console.error when dynamicParams = false rejects a param [2 pull requests, 1 comments, 2 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#90537Fetched 2026-04-08 00:19:58
View on GitHub
Comments
1
Participants
2
Timeline
10
Reactions
7
Timeline (top)
labeled ×3cross-referenced ×2referenced ×2commented ×1

Error Message

https://github.com/brysongilbert/nextjs-no-fallback-error-repro 2. cd nextjs-no-fallback-error-repro && npm install && npm run build 5. Visit http://localhost:3000/nonexistent — returns 404, but Error: Internal: NoFallbackError is logged to console.error The custom server intercepts console.error to highlight the leak. The error appears in both server modes. Current behavior: When dynamicParams = false is set and a request arrives for a param not in generateStaticParams, Next.js returns a correct 404 response but also logs Error: Internal: NoFallbackError to console.error. This is internal control-flow error handling leaking to the console. Expected behavior: The 404 response should be returned with no error logged to console.error. NoFallbackError is an internal mechanism — it should be caught silently, not surfaced as an error. Why this matters: APM tools (Datadog dd-trace, Sentry, New Relic) hook into console.error or intercept thrown errors during propagation. Every 404 from a dynamicParams = false route generates a false-positive error alert. At scale, bot traffic and crawlers hitting nonexistent paths produce hundreds of these per day, drowning out real errors. Dynamic Routes, Error Handling, Not Found This affects any infrastructure that wraps Next.js or monitors console.error:

  • APM tools (Datadog dd-trace, Sentry) — intercept thrown errors during propagation, reporting NoFallbackError as a real error even when it's caught internally The only current workaround is monkey-patching console.error to suppress NoFallbackError by string matching, which is fragile.

Fix Action

Fix / Workaround

The only current workaround is monkey-patching console.error to suppress NoFallbackError by string matching, which is fragile.

PR fix notes

PR #90554: fix: silence NoFallbackError in router-server outer catch

Description (problem / solution / changelog)

What?

Prevent NoFallbackError from being logged via console.error in the outer catch block of router-server.ts, and treat it as a 404 (not a 500).

Why?

NoFallbackError is internal control-flow — thrown by dynamicParams = false routes when an unknown param is requested. It is caught and handled inside handleRequest (correctly producing a 404 response), but in edge cases (e.g. when the not-found page itself triggers the error) it can propagate to the outer catch block.

Previously, the outer catch logged it via console.error and attempted to serve a 500 response. This causes:

  • False-positive APM alerts — Datadog dd-trace, Sentry, New Relic, and similar tools intercept console.error and report every bot crawl of a dynamicParams = false route as an application error.
  • Wrong HTTP status code — a NoFallbackError is semantically a 404, not a 500.

How?

Added an else if (err instanceof NoFallbackError) branch before the console.error call. When matched, it sets invokePath = '/404' and invokeStatus = '404' without logging.

Fixes #90537

Changed files

  • packages/next/src/server/lib/router-server.ts (modified, +7/-0)

PR #91128: fix: suppress NoFallbackError console.error when dynamicParams=false

Description (problem / solution / changelog)

What?

Suppresses NoFallbackError from being logged to console.error when dynamicParams = false correctly rejects a param with a 404 response.

Why?

NoFallbackError is an internal control-flow mechanism, not an actual error. When it leaks to console.error, APM tools (Datadog dd-trace, Sentry, New Relic) that hook into console.error generate false-positive error alerts. At scale, bot traffic hitting nonexistent paths produces hundreds of these alerts per day, drowning out real errors.

How?

Added NoFallbackError instance checks before console.error calls in four locations where the error could leak:

  1. response-cache/index.ts - Background revalidation catch block that logs errors when a cache entry was already resolved
  2. response-cache/web.ts - Same pattern for the web response cache
  3. router-server.ts - Top-level request handler catch that logs non-DecodeError exceptions
  4. base-server.ts renderToResponseImpl - When bubbleNoFallback is false (production bundles), handle NoFallbackError as a 404 instead of falling through to the generic error handler that calls logError

The 404 response behavior is preserved - only the spurious console.error output is suppressed.

Fixes #90537

This contribution was developed with AI assistance (Claude Code).

Changed files

  • packages/next/src/server/base-server.ts (modified, +6/-0)
  • packages/next/src/server/lib/router-server.ts (modified, +3/-0)
  • packages/next/src/server/response-cache/index.ts (modified, +8/-1)
  • packages/next/src/server/response-cache/web.ts (modified, +4/-1)
  • test/e2e/app-dir/dynamic-params-no-fallback-error/app/[slug]/page.tsx (added, +14/-0)
  • test/e2e/app-dir/dynamic-params-no-fallback-error/app/layout.tsx (added, +7/-0)
  • test/e2e/app-dir/dynamic-params-no-fallback-error/dynamic-params-no-fallback-error.test.ts (added, +23/-0)
  • test/e2e/app-dir/dynamic-params-no-fallback-error/next.config.js (added, +2/-0)

Code Example

git checkout next-16
npm install && npm run build
npm run start:custom

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jan 19 21:59:23 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 22.21.1
  npm: 10.9.4
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.1.6
  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/brysongilbert/nextjs-no-fallback-error-repro

To Reproduce

  1. Clone the reproduction repo
  2. cd nextjs-no-fallback-error-repro && npm install && npm run build
  3. Start the custom server: npm run start:custom
  4. Visit http://localhost:3000/about — returns 200, no errors in server console
  5. Visit http://localhost:3000/nonexistent — returns 404, but Error: Internal: NoFallbackError is logged to console.error
  6. Stop the server, run npm start (next start) instead — repeat steps 4–5, same NoFallbackError logged to console

The custom server intercepts console.error to highlight the leak. The error appears in both server modes.

The next-16 branch reproduces the same behavior on Next.js 16.1.6:

git checkout next-16
npm install && npm run build
npm run start:custom

Current vs. Expected behavior

Current behavior: When dynamicParams = false is set and a request arrives for a param not in generateStaticParams, Next.js returns a correct 404 response but also logs Error: Internal: NoFallbackError to console.error. This is internal control-flow error handling leaking to the console.

Expected behavior: The 404 response should be returned with no error logged to console.error. NoFallbackError is an internal mechanism — it should be caught silently, not surfaced as an error.

Why this matters: APM tools (Datadog dd-trace, Sentry, New Relic) hook into console.error or intercept thrown errors during propagation. Every 404 from a dynamicParams = false route generates a false-positive error alert. At scale, bot traffic and crawlers hitting nonexistent paths produce hundreds of these per day, drowning out real errors.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jan 19 21:59:23 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 22.21.1
  npm: 10.9.4
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.1.6
  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)

Dynamic Routes, Error Handling, Not Found

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

next start (local), Other (Deployed)

Additional context

This affects any infrastructure that wraps Next.js or monitors console.error:

  • Custom servers using getRequestHandler() — the standard Next.js custom server API
  • Netlify (@netlify/plugin-nextjs) — wraps getRequestHandler() and surfaces these in function logs
  • APM tools (Datadog dd-trace, Sentry) — intercept thrown errors during propagation, reporting NoFallbackError as a real error even when it's caught internally

The issue reproduces locally and on any platform. It is not browser-specific — it occurs server-side on every request to a dynamicParams = false route with an unknown param.

Tested on Next.js 15.5.12 and 16.1.6 — same behavior on both. Adding a custom not-found.tsx (root or segment level) has no effect.

The only current workaround is monkey-patching console.error to suppress NoFallbackError by string matching, which is fragile.

extent analysis

Fix Plan

1. Suppress NoFallbackError in custom server

Modify the custom server to catch and suppress NoFallbackError:

// custom-server.js
const { createServer } = require('http');
const { getRequestHandler } = require('next/dist/next-server/server/next-server');
const { console } = require('console');

const handler = getRequestHandler({
  // ... other options ...
});

createServer((req, res) => {
  try {
    handler(req, res);
  } catch (error) {
    if (error instanceof Error && error.message === 'Internal: NoFallbackError') {
      return res.status(404).end();
    }
    throw error;
  }
}).listen(3000, () => {
  console.log('Server listening on port 3000');
});

2. Suppress NoFallbackError in Next.js start

Modify the next.config.js file to catch and suppress NoFallbackError:

// next.config.js
module.exports = {
  // ... other options ...
  onDemandEntries: {
    // ... other options ...
    disable: true, // disable on-demand entries
  },
  async headers() {
    return [
      {
        source: '/:path*',
        headers: [
          {
            key: 'X-Error',
            value: (req, res) => {
              try {
                await res.next();
              } catch (error) {
                if (error instanceof Error && error.message === 'Internal: NoFallbackError') {
                  return '';
                }
                throw error;
              }
            },
          },
        ],
      },
    ];
  },
};

Verification

  1. Clone the reproduction repo and run npm install && npm run build.
  2. Start the custom server: npm run start:custom.
  3. Visit http://localhost:3000/about and `http://localhost:3000

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 NoFallbackError logged to console.error when dynamicParams = false rejects a param [2 pull requests, 1 comments, 2 participants]