Commit 4a4e903
committed
When deeply nested Suspense boundaries inside a fallback of another boundary resolve it is possible to encounter situations where you either attempt to flush an aborted Segment or you have a boundary without any root segment. We intended for both of these conditions to be impossible to arrive at legitimately however it turns out in this situation you can. The fix is two-fold
1. allow flushing aborted segments by simply skipping them. This does remove some protection against future misconfiguraiton of React because it is no longer an invariant that you hsould never attempt to flush an aborted segment but there are legitimate cases where this can come up and simply omitting the segment is fine b/c we know that the user will never observe this. A semantically better solution would be to avoid flushing boudaries inside an unneeded fallback but to do this we would need to track all boundaries inside a fallback or create back pointers which add to memory overhead and possibly make GC harder to do efficiently. By flushing extra we're maintaining status quo and only suffer in performance not with broken semantics.
2. when queuing completed segments allow for queueing aborted segments and if we are eliding the enqueued segment allow for child segments that are errored to be enqueued too. This will mean that we can maintain the invariant that a boundary must have a root segment the first time we flush it, it just might be aborted (see point 1 above).
This change has two seemingly similar test cases to exercise this fix. The reason we need both is that when you have empty segments you hit different code paths within Fizz and so each one (without this fix) triggers a different error pathway.1 parent 6ccf328 commit 4a4e903
File tree
3 files changed
+119
-4
lines changed- packages
- react-dom/src/__tests__
- react-server/src
3 files changed
+119
-4
lines changedLines changed: 107 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
10447 | 10448 | | |
10448 | 10449 | | |
10449 | 10450 | | |
| 10451 | + | |
| 10452 | + | |
| 10453 | + | |
| 10454 | + | |
| 10455 | + | |
| 10456 | + | |
| 10457 | + | |
| 10458 | + | |
| 10459 | + | |
| 10460 | + | |
| 10461 | + | |
| 10462 | + | |
| 10463 | + | |
| 10464 | + | |
| 10465 | + | |
| 10466 | + | |
| 10467 | + | |
| 10468 | + | |
| 10469 | + | |
| 10470 | + | |
| 10471 | + | |
| 10472 | + | |
| 10473 | + | |
| 10474 | + | |
| 10475 | + | |
| 10476 | + | |
| 10477 | + | |
| 10478 | + | |
| 10479 | + | |
| 10480 | + | |
| 10481 | + | |
| 10482 | + | |
| 10483 | + | |
| 10484 | + | |
| 10485 | + | |
| 10486 | + | |
| 10487 | + | |
| 10488 | + | |
| 10489 | + | |
| 10490 | + | |
| 10491 | + | |
| 10492 | + | |
| 10493 | + | |
| 10494 | + | |
| 10495 | + | |
| 10496 | + | |
| 10497 | + | |
| 10498 | + | |
| 10499 | + | |
| 10500 | + | |
| 10501 | + | |
| 10502 | + | |
| 10503 | + | |
| 10504 | + | |
| 10505 | + | |
| 10506 | + | |
| 10507 | + | |
| 10508 | + | |
| 10509 | + | |
| 10510 | + | |
| 10511 | + | |
| 10512 | + | |
| 10513 | + | |
| 10514 | + | |
| 10515 | + | |
| 10516 | + | |
| 10517 | + | |
| 10518 | + | |
| 10519 | + | |
| 10520 | + | |
| 10521 | + | |
| 10522 | + | |
| 10523 | + | |
| 10524 | + | |
| 10525 | + | |
| 10526 | + | |
| 10527 | + | |
| 10528 | + | |
| 10529 | + | |
| 10530 | + | |
| 10531 | + | |
| 10532 | + | |
| 10533 | + | |
| 10534 | + | |
| 10535 | + | |
| 10536 | + | |
| 10537 | + | |
| 10538 | + | |
| 10539 | + | |
| 10540 | + | |
| 10541 | + | |
| 10542 | + | |
| 10543 | + | |
| 10544 | + | |
| 10545 | + | |
| 10546 | + | |
| 10547 | + | |
| 10548 | + | |
| 10549 | + | |
| 10550 | + | |
| 10551 | + | |
| 10552 | + | |
| 10553 | + | |
| 10554 | + | |
| 10555 | + | |
| 10556 | + | |
10450 | 10557 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4918 | 4918 | | |
4919 | 4919 | | |
4920 | 4920 | | |
4921 | | - | |
| 4921 | + | |
| 4922 | + | |
| 4923 | + | |
| 4924 | + | |
| 4925 | + | |
4922 | 4926 | | |
4923 | 4927 | | |
4924 | 4928 | | |
| |||
4989 | 4993 | | |
4990 | 4994 | | |
4991 | 4995 | | |
4992 | | - | |
| 4996 | + | |
4993 | 4997 | | |
4994 | 4998 | | |
4995 | 4999 | | |
| |||
5058 | 5062 | | |
5059 | 5063 | | |
5060 | 5064 | | |
5061 | | - | |
| 5065 | + | |
5062 | 5066 | | |
5063 | 5067 | | |
5064 | 5068 | | |
| |||
5575 | 5579 | | |
5576 | 5580 | | |
5577 | 5581 | | |
| 5582 | + | |
| 5583 | + | |
| 5584 | + | |
5578 | 5585 | | |
5579 | 5586 | | |
5580 | 5587 | | |
| |||
0 commit comments