Commit Graph

28 Commits

Author SHA1 Message Date
Jiwon Choi d7aa66c345 Remove generated error codes (#97687)
### Why?

Should come up with better solution that does not block PRs with git
conflict

x-ref:
https://vercel.slack.com/archives/C02CDC2ALJH/p1785263902728189?thread_ts=1785263687.502649&cid=C02CDC2ALJH

### How?

- Delete `errors.json`, the error-code SWC plugin, generated WASM, merge
driver, and validation/build tooling.
- Stop attaching error codes to server-rendering digests, redboxes, and
telemetry; native `Error.code` and `Error.name` remain available where
applicable.
- Remove the development-overlay error feedback UI, middleware, and
telemetry event that depended on stable codes.
- Update fixtures, snapshots, and guidance for code-free errors and
numeric-only digests.

<!-- NEXT_JS_LLM -->
2026-08-21 22:45:12 +02:00
Vercel Release Bot f90e8bd21a Upgrade React from d9158919-20260615 to ad78e251-20260616 (#94867)
Co-authored-by: next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
2026-06-17 15:19:35 +02:00
Jiwon Choi 74ce6b2e2f Reapply "Stabilize catchError and retry by removing unstable_ prefix" (#94623)
### What?

Reverts #94617, which had reverted #94610. This re-lands the
stabilization of the `catchError` API and the `retry` error prop by
removing their `unstable_` prefix across source, docs, and tests.

### Why?

#94610 was reverted in #94617 to unblock another change. This re-applies
it now that it is no longer blocked.

### How?

`git revert` of the revert commit. The repo's custom errors.json merge
driver handled the error registry: the original codes `1324`/`1325` had
been reclaimed by `instant` errors after the revert, so the reintroduced
messages were minted as new codes `1360` (`retry()` can only be used in
the App Router) and `1361` (`catchError` can only be used in Client
Components), keeping errors.json append-only.

The docs changelog adds `v16.3.0 | catchError became stable.` while
retaining the historical `v16.2.0 | unstable_catchError introduced.`
row.

### Verification

- `pnpm update-error-codes` (check_error_codes passes; errors.json in
sync)
- `pnpm build` (full JS build, exit 0)
- `pnpm --filter=next types` (exit 0)
- Not run: Rust/cargo build (`react_server_components.rs` change is a
one-line allow-list string revert; left to CI)

<!-- NEXT_JS_LLM_PR -->
2026-06-09 16:11:44 -07:00
Jiwon Choi 3d920355dd Revert "Stabilize catchError and retry by removing unstable_ prefix" (#94617)
Reverts vercel/next.js#94610

Unblock
2026-06-09 19:47:48 +00:00
Jiwon Choi 6b3936a332 Stabilize catchError and retry by removing unstable_ prefix (#94610)
### What?

Promotes two experimental error-handling APIs to stable by dropping the
`unstable_` prefix:

- `unstable_catchError` → `catchError` (exported from `next/error`)
- `unstable_retry` → `retry` (the prop Next.js injects into `error.js` /
`global-error.js` boundaries and `catchError` fallbacks)

### Why?

Both were introduced as `unstable_` in `v16.2.0` and are now stable as
of `v16.3.0`. The experimental prefix should be removed from the stable
surface.

### How?

- Renamed the `next/error` export (`error.d.ts`, `error.js`,
`src/api/error.ts`, `src/api/error.react-server.ts`) and the
implementation in `client/components/catch-error.tsx`.
- Renamed the framework-injected `retry` prop across
`error-boundary.tsx`, `builtin/global-error.tsx`, the dev-overlay error
boundary, and the `ErrorInfo` type.
- Updated the RSC client-only export list in the SWC transform
(`react_server_components.rs`) so importing `catchError` in a Server
Component still produces the "only available in Client Components"
error.
- Updated the thrown error messages and their `errors.json` entries
(codes 1138/1139), the TypeScript-plugin serialization-exemption rule,
all affected tests, the rspack test manifests, and the docs.
- Docs version-history tables keep the historical `unstable_` rows and
add a `v16.3.0` row noting the rename to stable.

This is a clean rename with **no** backward-compatible `unstable_`
alias.

### Verification

- Passed: pre-commit hooks (`prettier`, `eslint --fix`, `rustfmt`) on
all 35 changed files.
- Passed: repo-wide grep confirms no remaining `unstable_catchError` /
`unstable_retry` outside the intended historical version-history rows.
- In progress locally (covered by CI): `pnpm build-all` (native SWC
still compiling on a fresh worktree), then `pnpm --filter=next types`
and the targeted e2e suites (`app-dir/catch-error`, `app-dir/errors`,
`rsc-build-errors`, typescript-plugin `client-boundary`).

<!-- NEXT_JS_LLM_PR -->
2026-06-09 21:05:02 +02:00
Janka Uryga ea541987d1 fix: handling of falsey values in error boundaries (#93134)
our error boundaries had a bunch of logic that set `state.error = error`
and then checked `if (state.error)`, which only works correctly if
thrown value is truthy. it breaks if something does e.g. `throw
undefined`. in this case, we would incorrectly think that no error
occurred and render children again (instead of a fallback), which can
then lead to an infinite loop if the children throw again.

the fix is to wrap the thrown value, so `state.error` is either `null`
(initial/reset) or `{ thrownValue: ... }` if something errored. i
initially considered using a separate `state.hasError` boolean, but
that's a bit annoying to type, and really we want to model this as a
discriminated union, so using a pseudo-Optional thing is nicer.
2026-04-29 17:25:56 +00:00
nextjs-bot 4fc3664eed Upgrade React from fef12a01-20260413 to da9325b5-20260417 (#92945)
[diff facebook/react@fef12a01...da9325b5](https://github.com/facebook/react/compare/fef12a01...da9325b5)

<details>
<summary>React upstream changes</summary>

- https://github.com/facebook/react/pull/35962
- https://github.com/facebook/react/pull/35961
- https://github.com/facebook/react/pull/36277
- https://github.com/facebook/react/pull/36297
- https://github.com/facebook/react/pull/36292
- https://github.com/facebook/react/pull/36291
- https://github.com/facebook/react/pull/36196
- https://github.com/facebook/react/pull/36246
- https://github.com/facebook/react/pull/36287
- https://github.com/facebook/react/pull/36285
- https://github.com/facebook/react/pull/36274
- https://github.com/facebook/react/pull/36266
- https://github.com/facebook/react/pull/36253

</details>
2026-04-20 09:00:53 +02:00
Sebastian "Sebbie" Silbermann b9ca95c62d Don't swallow strings thrown in Server Components (#92592) 2026-04-09 23:30:09 +00:00
Mitul Shah ad3296b9d4 Update default error pages (#90469)
Redesign the https://github.com/vercel/next.js/pull/87988 error pages to
be more aligned with Next.js aesthetic, along with copy to be sharper.

| Client | Server |
|--------|--------|
| <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 26
07@2x"
src="https://github.com/user-attachments/assets/f42bee3e-2ce8-44dc-9e26-79b81cf965d8"
/> | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 23
38@2x"
src="https://github.com/user-attachments/assets/19a596c6-6da7-4a42-9b53-16e3c2e6f867"
/> |
| <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 25
22@2x"
src="https://github.com/user-attachments/assets/a3075d79-c76a-4fbf-af6e-d4a44f1434eb"
/> | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 24
17@2x"
src="https://github.com/user-attachments/assets/5811cc98-f8e4-4451-bf9c-501548292245"
/> |

---------

Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2026-03-04 12:49:57 +01:00
Jiwon Choi 9d13b676e8 Add unstable_retry() to error.js (#89685)
Extends the error components API to give better control over recovery.
Previously, the `reset()` prop only cleared the error state and
re-rendered the children. However, this only handles a temporary
rendering error.

The error can be due to data fetching or an RSC phase. In these cases,
`reset()` alone is not sufficient. Users would even need to implement
retry logic using `router.refresh()`.

Therefore, this PR adds a new `unstable_retry()` prop that calls
`router.refresh()` and `reset()` within a `startTransition()` to provide
built-in retry logic. This feature is expected to be preferred over the
`reset()` prop. Only the cases where you'd choose `reset()` are when you
have a reason to do a sync reset without loading any new data.

Closes NAR-767
2026-02-26 21:22:27 +01:00
Jimmy Lai c74cb2ae25 Redesign default error pages with cleaner, more user-friendly UI (#87988)
- redesigns the default global + default error boundaries. removing the
WSOD forever :/
- adds dark mode support
- unifies a bit of the styling
- add the digest for the server error
- adds a return button on the client errors

<img width="3328" height="1914" alt="CleanShot 2026-01-02 at 09 46
36@2x"
src="https://github.com/user-attachments/assets/9994eb37-c22b-4847-9a18-e9acf0ae6236"
/>

<img width="2144" height="1242" alt="CleanShot 2026-01-02 at 09 47
01@2x"
src="https://github.com/user-attachments/assets/9b3bcf39-63f6-4c8d-85c5-2976c25f5b7b"
/>


<img width="2238" height="1632" alt="CleanShot 2026-01-02 at 09 47
17@2x"
src="https://github.com/user-attachments/assets/436433d7-9873-496a-9c96-536e070be9d7"
/>
<img width="1708" height="1260" alt="CleanShot 2026-01-02 at 09 47
23@2x"
src="https://github.com/user-attachments/assets/1ec42402-dbd9-41a3-801b-4745a4f128f7"
/>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-05 13:30:06 +01:00
Hendrik Liebau 3b8cd9225b Fix error logging for 'use cache' runtime errors in production (#86500)
In production, when throwing an error in `'use cache'` at runtime, we
are currently logging the obfuscated error that React is producing when
crossing the cache-server boundary. This is not ideal for investigating
production issues so we're also logging the original error in the `'use
cache'` wrapper as a work-around. But this error does not have a digest,
which makes it non-obvious that it's the same error as the obfuscated
one.

With this PR we are fixing this by storing the original error (with a
digest) in the `reactServerErrorsByDigest` map (moved to the work
store), and retrieving it in the server environment when we log the
error. Thus the obfuscated error is not logged, and the original error
with a digest is logged instead.

In development, we keep the existing behavior of logging the transported
error, which also includes the dev-only `environmentName` property
`'Cache'`.

As part of this fix, we're consolidating the
`createFlightReactServerErrorHandler` and
`createHTMLReactServerErrorHandler` functions, which had a big overlap
and confusing names, into a single `createReactServerErrorHandler`
function.

closes NAR-536
2025-11-27 20:25:32 +01:00
Sebastian "Sebbie" Silbermann 0b58a32c45 [test] assert* -> waitFor* when the util is not instant (#85450) 2025-10-30 14:44:08 +01:00
Vercel Release Bot 04ca99dc56 Upgrade React from 79d9aed7-20250620 to 06e89951-20250620 (#80730)
Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
2025-06-20 18:40:06 +00:00
Sebastian "Sebbie" Silbermann 6a0b7e9059 Upgrade React from 197d6a04-20250424 to 79d9aed7-20250620 (#79477) 2025-06-20 15:47:45 +02:00
Sebastian "Sebbie" Silbermann 8ea7d4bb35 [dev-overlay] Move error.name to label (#78198) 2025-04-25 11:00:58 +02:00
Sebastian "Sebbie" Silbermann b9d65b8afe [test] Assert on all errors in Redbox matchers (#77907) 2025-04-10 10:00:42 +02:00
Sebastian "Sebbie" Silbermann 855670e836 [dev-overlay] Remove "Unhandled Runtime Error" label (#77484) 2025-03-25 14:10:35 -07:00
Sebastian "Sebbie" Silbermann 871ca31e60 [app] Send errors not handled by explicit error boundaries through reportError (#76101) 2025-02-24 17:59:22 +01:00
Sebastian "Sebbie" Silbermann c02bca2322 Current behavior for reportError (#76115) 2025-02-17 22:02:08 +01:00
Zack Tanner f872b6dee5 add hostname to default error boundary message (#75151)
Since it's possible to deploy an application that triggers our default
exception handling, we should ensure the error text is personalized to
the host application to avoid any potential incorrect canonicalization
by search engines for containing duplicate content.

[slack
context](https://vercel.slack.com/archives/C01A2M9R8RZ/p1737475474278219?thread_ts=1737385764.035219&cid=C01A2M9R8RZ)
2025-01-21 16:05:27 -08:00
Sebastian "Sebbie" Silbermann 98de5db6d4 Use consistent error formatting in terminal (#71909) 2024-12-06 14:43:59 +01:00
Jiachi Liu f91cdec44d test: migrate rest async api usage in tests (#71663) 2024-10-23 02:36:20 +02:00
Sebastian "Sebbie" Silbermann 94060f2b98 Handle thrown values that aren't Error instances in App router (#71210) 2024-10-13 16:14:08 +02:00
Sebastian "Sebbie" Silbermann a135e7fb5e Improve error digest test suite (#71209) 2024-10-13 14:24:42 +02:00
Sebastian Silbermann fe8d953e2d Replace hasRedbox() (#67025)
...with `assertHasRedbox` and `assertNoRedbox`.

`hasRedbox()` has a hardcoded timeout of 5s that is only required for
the negative assertion.
Instead, we now have dedicated assertions for the positive
(`assertHasRedbox`) and negative case (`assertNoRedbox`).
The negative assertion still has the hardcoded timeout.
But the positive assertion just retries until we find the Redbox.

This speeds up tests using the positive assertion.
Removing `hasRedbox` also uncovered some unused expressions e.g. `await
hasRedbox(browser)`.
These expressions probably wanted to use `expect(await
hasRedbox(browser)).toBe(true)
2024-06-20 10:37:32 +02:00
Wyatt Johnson c6320ed87a Replace createNextDescribe with nextTestSetup (#64817)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

I took some time and [wrote a
codemod](https://gist.github.com/wyattjoh/0d4464427506cb02062a4729ca906b62)
that replaces the old usage of the `createNextDescribe` with the new
`nextTestSetup`. You'll likely have to turn on hiding of whitespace in
order to review, but this should primarily introduce no changes to the
test structure other than using the new mechanism now.

Closes NEXT-3178
2024-04-25 12:06:12 -06:00
Jiachi Liu 92e4a4b78c Associate server error digest with browser logged one (#61592)
### What

#### Core
This PR respect the error's digest when recieves new error occurred from
server side, and it will be logged into client on production with the
same `digest` property.
If we discover the original RSC error in SSR error handler, retrieve the
original error

#### Tests

* Move the errors related tests from `test/e2e/app-dir/app` to a
separate test suite `test/e2e/app-dir/errors`
* Add a new test case for logging the original RSC error
* Add a new test case for logging the original Server Action error


### Why

This will help associate the `digest` property of the errors logged from
client with the actual generated server errors. Previously they're
different as we might re-compute the digest proper in handler that react
server renderer thinks it's a new error, which causes we have 2
different errors logged on server side, and 1 logged on client side. The
one on client side can associate to the server errors but it's from
react renderer which is not the original error.

Closes NEXT-2094
Fixes #60684
2024-02-06 13:39:12 +01:00