Commit 23142b0
committed
Bugfix: Don't rely on
I recently started using `pendingPassiveEffectsLanes` to check if there were any pending
passive effects (530027a). `pendingPassiveEffectsLanes` is the value of
`root.finishedLanes` at the beginning of the commit phase. When there
are pending passive effects, it should always be a non-zero value,
because it represents the lanes used to render the effects.
But it turns out that `root.finishedLanes` isn't always correct.
Sometimes it's `NoLanes` even when there's a new commit.
I found this while investigating an internal bug report. The only repro
I could get was via a headless e2e test runner; I couldn't get one in an
actual browser, or other interactive environment. I used the e2e test to
bisect and confirm the fix. But I don't know yet know how to write a
regression test for the precise underlying scenario. I can probably
reverse engineer one by studying the code; after a quick glance
at `performConcurrentWorkOnRoot` and `performSyncWorkOnRoot`, it's not
hard to see how this might happen.
In the meantime, I'll revert the recent change that exposed the bug.
I was surprised that this had never come up before, since the code that
assigns `root.finishedLanes` is in an extremely hot path, and it hasn't
changed in a while. The reason is that, before 530027a,
`root.finishedLanes` was only used by the DevTools profiler, which is
probably why we had never noticed any issues. In addition to fixing the
inconsistency, we might also consider making `finishedLanes` a
profiling-only field.finishedLanes for passive effects (facebook#21233)1 parent 4472d75 commit 23142b0
File tree
2 files changed
+18
-2
lines changed- packages/react-reconciler/src
2 files changed
+18
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2007 | 2007 | | |
2008 | 2008 | | |
2009 | 2009 | | |
2010 | | - | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
2011 | 2016 | | |
2012 | 2017 | | |
2013 | 2018 | | |
| |||
2042 | 2047 | | |
2043 | 2048 | | |
2044 | 2049 | | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
2045 | 2053 | | |
2046 | 2054 | | |
2047 | 2055 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2007 | 2007 | | |
2008 | 2008 | | |
2009 | 2009 | | |
2010 | | - | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
2011 | 2016 | | |
2012 | 2017 | | |
2013 | 2018 | | |
| |||
2042 | 2047 | | |
2043 | 2048 | | |
2044 | 2049 | | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
2045 | 2053 | | |
2046 | 2054 | | |
2047 | 2055 | | |
| |||
0 commit comments