Move Hydration Mismatch Errors to Throw or Log Once (Kind of)
Stacked on #28476.
We used to console.error for every mismatch we found, up until the error we threw for the hydration mismatch.
This changes it so that we build up a set of diffs up until we either throw or complete hydrating the root/suspense boundary. If we throw, we append the diff to the error message which gets passed to onRecoverableError (which by default is also logged to console). If we complete, we append it to a console.error.
Since we early abort when something throws, it effectively means that we can only collect multiple diffs if there were preceding non-throwing mismatches - i.e. only properties mismatched but tag name matched.
There can still be multiple logs if multiple siblings Suspense boundaries all error hydrating but then they're separate errors entirely.
We still log an extra line about something erroring but I think the goal should be that it leads to a single recoverable or console.error.
This doesn't yet actually print the diff as part of this message. That's in a follow up PR.
Comparing: 4b8dfd6215bf855402ae1a94cb0ae4f467afca9a...ec5901d9724af6ccbacd5d7612ada5a285cd61ed
Critical size changes
Includes critical production bundles, as well as any change greater than 2%:
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
|---|---|---|---|---|---|---|
| oss-stable/react-dom/cjs/react-dom.production.min.js | = | 175.92 kB | 175.85 kB | = | 54.70 kB | 54.68 kB |
| oss-experimental/react-dom/cjs/react-dom.production.min.js | = | 172.41 kB | 172.33 kB | = | 53.84 kB | 53.81 kB |
| facebook-www/ReactDOM-prod.classic.js | = | 589.78 kB | 589.61 kB | = | 103.78 kB | 103.77 kB |
| facebook-www/ReactDOM-prod.modern.js | = | 573.30 kB | 573.13 kB | = | 100.82 kB | 100.81 kB |
| test_utils/ReactAllWarnings.js | Deleted | 65.27 kB | 0.00 kB | Deleted | 16.17 kB | 0.00 kB |
Significant size changes
Includes any change greater than 0.2%:
Expand to show
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
|---|---|---|---|---|---|---|
| test_utils/ReactAllWarnings.js | Deleted | 65.27 kB | 0.00 kB | Deleted | 16.17 kB | 0.00 kB |
Generated by :no_entry_sign: dangerJS against ec5901d9724af6ccbacd5d7612ada5a285cd61ed
Stamped downstream.