Commit 769cfc7
committed
Bugfix: Synchronous ping during render phase sometimes unwinds the stack, leading to crash (#25851)
I found this bug when working on a different task.
`pingSuspendedRoot` sometimes calls `prepareFreshStack` to interupt the
work-in-progress tree and force a restart from the root. The idea is
that if the current render is already in a state where it be blocked
from committing, and there's new data that could unblock it, we might as
well restart from the beginning.
The problem is that this is only safe to do if `pingSuspendedRoot` is
called from a non-React task, like an event handler or a microtask.
While this is usually the case, it's entirely possible for a thenable to
resolve (i.e. to call `pingSuspendedRoot`) synchronously while the
render phase is already executing. If that happens, and work loop
attempts to unwind the stack, it causes the render phase to crash.
DiffTrain build for [5fcf1a4](5fcf1a4)
[View git log for this commit](https://github.com/facebook/react/commits/5fcf1a4b4c2150a1b9fe0de0144a82a053c63966)1 parent ecbf597 commit 769cfc7
28 files changed
Lines changed: 90 additions & 66 deletions
File tree
- compiled/facebook-www
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
646 | | - | |
| 646 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
654 | 654 | | |
655 | 655 | | |
656 | 656 | | |
657 | | - | |
| 657 | + | |
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
649 | | - | |
| 649 | + | |
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
25766 | 25766 | | |
25767 | 25767 | | |
25768 | 25768 | | |
25769 | | - | |
25770 | | - | |
| 25769 | + | |
| 25770 | + | |
| 25771 | + | |
| 25772 | + | |
| 25773 | + | |
25771 | 25774 | | |
25772 | 25775 | | |
25773 | 25776 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
25455 | 25455 | | |
25456 | 25456 | | |
25457 | 25457 | | |
25458 | | - | |
25459 | | - | |
| 25458 | + | |
| 25459 | + | |
| 25460 | + | |
| 25461 | + | |
| 25462 | + | |
25460 | 25463 | | |
25461 | 25464 | | |
25462 | 25465 | | |
| |||
0 commit comments