react/scripts
Sebastian Markbåge 6090cab099
Use a Wrapper Error for onRecoverableError with a "cause" Field for the real Error (#28736)
We basically have four kinds of recoverable errors:

- Hydration mismatches.
- Server errored but client didn't.
- Hydration render errored but client render didn't (in Root or Suspense
boundary).
- Concurrent render errored but synchronous render didn't.

For the first three we log an additional error that the root or Suspense
boundary didn't error. This provides some context about what happened.
However, the problem is that for hydration mismatches that's unnecessary
extra context that is confusing. We also don't log any additional
context for concurrent render errors that could recover. This used to be
the only recoverable error so it didn't need extra context but now we
need to distinguish them. When we log these to `reportError` it's
confusing to just see the error because you didn't see anything error on
the page. It's also hard to group them together as one.

In this PR, I remove the unnecessary context for hydration mismatches.

For hydration and concurrent errors, I now wrap them in an error that
describes that what happened but then use the new `cause` field to link
the original error so we can keep that as the cause. The error that
happened was that hydration client rendered or you deopted to sync
render, the cause of that error is some other error.

For server errors, we control the Error object so I already had added
some context to that error object's message. Since we hide the message
in prod, it's nice not to have the raw message in DEV neither. We could
potentially split these into two errors for parity though.
2024-04-03 21:53:07 -04:00
..
babel Include regular stack trace in serialized errors from Fizz (#28684) 2024-03-30 11:08:54 -04:00
bench Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
circleci Remove @providesModule remnants (#28720) 2024-04-03 09:10:00 -04:00
devtools chore[devtools/release-scripts]: update messages / fixed npm view com… (#26660) 2023-04-19 10:05:16 +01:00
error-codes Use a Wrapper Error for onRecoverableError with a "cause" Field for the real Error (#28736) 2024-04-03 21:53:07 -04:00
eslint [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
eslint-rules Support Flow as expressions in ESLint rules (#27590) 2023-11-01 15:24:06 -04:00
flags Better NEXT_MAJOR support for RN flags (#28583) 2024-03-22 13:02:04 -04:00
flow Update RN dynamic flag types (#28427) 2024-03-22 12:23:38 -04:00
git Remove leftover env variable logic in pre-commit hook 2015-09-01 14:35:47 -07:00
jest Move console mocks to internal-test-utils (#28710) 2024-04-03 16:02:04 -04:00
perf-counters [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
prettier [useFormState] Allow sync actions (#27571) 2023-10-31 23:32:31 -04:00
print-warnings Remove WARNINGS file from FB (#27820) 2023-12-08 16:21:15 -05:00
release Added windows powershell syntax to build scripts (#27692) 2023-11-16 11:35:43 +00:00
rollup Remove @providesModule remnants (#28720) 2024-04-03 09:10:00 -04:00
shared Rename "shared subset" to "server" (#27939) 2024-01-16 19:58:11 -05:00
tasks Bug: yarn flow dom does not exist, so console should suggest yarn flow dom-node (#26213) 2023-02-21 21:30:34 +01:00
authors AUTHORS 2013-09-09 23:42:54 -07:00