nextjs - ✅(Solved) Fix Refreshing page while router.refresh() is in flight triggers an error boundary [1 pull requests, 1 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#87681Fetched 2026-04-08 02:06:38
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
subscribed ×2cross-referenced ×1issue_type_added ×1labeled ×1

Error Message

  1. error boundary is triggered This triggers an error boundary, but I'm not sure why? It's a degraded experience that doesn't need to happen.

Fix Action

Fixed

PR fix notes

PR #88115: fix: suppress error boundary flash during page unload

Description (problem / solution / changelog)

Summary

  • Fixes error boundary briefly flashing when router.refresh() is interrupted by page reload
  • Checks isPageUnloading in error boundary render method to suppress error UI during page unload

Test plan

  • Added test that simulates mid-stream RSC fetch abort during page unload
  • Test verifies error boundary does NOT render when page is unloading
  • All existing refresh tests continue to pass

Fixes #87681

Changed files

  • packages/next/src/client/components/error-boundary.tsx (modified, +5/-2)
  • packages/next/src/client/components/router-reducer/fetch-server-response.ts (modified, +4/-0)
  • test/e2e/app-dir/refresh/app/refresh-during-unload/client.tsx (added, +33/-0)
  • test/e2e/app-dir/refresh/app/refresh-during-unload/error.tsx (added, +30/-0)
  • test/e2e/app-dir/refresh/app/refresh-during-unload/page.tsx (added, +13/-0)
  • test/e2e/app-dir/refresh/refresh.test.ts (modified, +92/-0)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.18.0
  npm: 11.3.0
  Yarn: 1.22.22
  pnpm: 10.11.0
Relevant Packages:
  next: 16.1.1 // Latest available version is detected (16.1.1).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: standalone
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/agitated-engelbart-df7742

To Reproduce

  1. call router.refresh()
  2. refresh the page mid-stream
  3. error boundary is triggered

Current vs. Expected behavior

This triggers an error boundary, but I'm not sure why? It's a degraded experience that doesn't need to happen.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.18.0
  npm: 11.3.0
  Yarn: 1.22.22
  pnpm: 10.11.0
Relevant Packages:
  next: 16.1.1 // Latest available version is detected (16.1.1).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: standalone

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

Linking and Navigating

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

Other (Deployed)

Additional context

Happens locally and in prod

extent analysis

TL;DR

The error boundary trigger during page refresh mid-stream may be resolved by implementing a more robust error handling mechanism or adjusting the router refresh logic.

Guidance

  • Review the router.refresh() call to ensure it's properly handling asynchronous operations and potential errors.
  • Investigate the error boundary trigger to determine the specific error causing the degraded experience.
  • Consider implementing a retry mechanism or a more robust error handling strategy to mitigate the issue.
  • Verify the behavior in different environments and browsers to rule out any platform-specific issues.

Example

No specific code snippet can be provided without further information on the router.refresh() implementation and the error boundary trigger.

Notes

The issue seems to be related to the router.refresh() call and the error boundary trigger, but more information is needed to provide a definitive solution. The provided environment information and package versions may be relevant, but their impact on the issue is unclear.

Recommendation

Apply workaround: Implement a more robust error handling mechanism, such as retrying the router.refresh() call or displaying a user-friendly error message, to mitigate the degraded experience. This approach is recommended because it allows for a more controlled and user-friendly error handling experience, even if the root cause of the issue is not fully understood.

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