Commit 4db23e0
committed
Avoid accumulating hydration mismatch errors after the first hydration error
If there is a suspended component or an error during hydration there will almost certainly be many additional hydration mismatch errors because the hydration target does not pair up the server rendered html with an expected slot on the client. To avoid spamming users with warnings there was already logic in place to suppress console warnings if such an occurrence happens. This commit takes another approach to avoid queueing thrown errors.
when suspending this isn't that big of an issue becuase queued errors are discarded becasue the suspense boundary does not complete.
When erroring within a resolved suspense boundary however the root completes and all queued errors are upgraded to recoverable errors and in many cases wihll flood the console. What is worse is the console warnings which offer much more specific guidance on what went wrong (in dev) are suppressed so the user is left with very little actionable information on which to go on and the volume of mismatch errors may distract from identifying the root cause error
The hueristic is as follows
1. always queue the first error during hydration
2. always queue non hydration mismatch errors
2. discard hydration mismatch errors before queueing If there is an already queued error or any type1 parent bd08137 commit 4db23e0
File tree
2 files changed
+40
-22
lines changed- packages
- react-dom/src/__tests__
- react-reconciler/src
2 files changed
+40
-22
lines changedLines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2976 | 2976 | | |
2977 | 2977 | | |
2978 | 2978 | | |
2979 | | - | |
2980 | | - | |
2981 | 2979 | | |
2982 | 2980 | | |
2983 | 2981 | | |
| |||
3069 | 3067 | | |
3070 | 3068 | | |
3071 | 3069 | | |
3072 | | - | |
3073 | | - | |
3074 | 3070 | | |
3075 | 3071 | | |
3076 | 3072 | | |
| |||
Lines changed: 40 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
| 389 | + | |
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| 393 | + | |
| 394 | + | |
393 | 395 | | |
394 | 396 | | |
395 | 397 | | |
| |||
448 | 450 | | |
449 | 451 | | |
450 | 452 | | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
466 | 478 | | |
467 | | - | |
468 | 479 | | |
469 | 480 | | |
470 | 481 | | |
| |||
675 | 686 | | |
676 | 687 | | |
677 | 688 | | |
| 689 | + | |
678 | 690 | | |
679 | 691 | | |
680 | | - | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
681 | 703 | | |
682 | 704 | | |
683 | 705 | | |
| |||
0 commit comments