Commit 42e04b4
authored
Fix: Detach deleted fiber's alternate, too (#20587)
We need to call `detachFiberAfterEffects` on the fiber's alternate to
clean it up. We're currently not, because the `alternate` field is
cleared during `detachFiberMutation`. So I deferred detaching the
`alternate` until the passive phase. Only the `return` pointer needs to
be detached for semantic purposes.
I don't think there's any good way to test this without using
reflection. It's not even observable using out our "supported"
reflection APIs (`findDOMNode`), or at least not that I can think of.
Which is a good thing, in a way.
It's not really a memory leak, either, because the only reference to the
alternate fiber is from the parent's alternate. Which will be
disconnected the next time the parent is updated or deleted.
It's really only observable if you mess around with internals in ways
you're not supposed to — I found it because a product test in www that
uses Enzyme was doing just that.
In lieu of a new unit test, I confirmed this patch fixes the broken
product test.1 parent a656ace commit 42e04b4
File tree
4 files changed
+26
-10
lines changed- packages/react-reconciler/src
4 files changed
+26
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1084 | 1084 | | |
1085 | 1085 | | |
1086 | 1086 | | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
1092 | 1091 | | |
1093 | 1092 | | |
1094 | 1093 | | |
1095 | 1094 | | |
1096 | 1095 | | |
1097 | 1096 | | |
| 1097 | + | |
1098 | 1098 | | |
1099 | 1099 | | |
1100 | 1100 | | |
| |||
1936 | 1936 | | |
1937 | 1937 | | |
1938 | 1938 | | |
| 1939 | + | |
1939 | 1940 | | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
1940 | 1944 | | |
1941 | 1945 | | |
1942 | 1946 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1084 | 1084 | | |
1085 | 1085 | | |
1086 | 1086 | | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
1092 | 1091 | | |
1093 | 1092 | | |
1094 | 1093 | | |
1095 | 1094 | | |
1096 | 1095 | | |
1097 | 1096 | | |
| 1097 | + | |
1098 | 1098 | | |
1099 | 1099 | | |
1100 | 1100 | | |
| |||
1936 | 1936 | | |
1937 | 1937 | | |
1938 | 1938 | | |
| 1939 | + | |
1939 | 1940 | | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
1940 | 1944 | | |
1941 | 1945 | | |
1942 | 1946 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2148 | 2148 | | |
2149 | 2149 | | |
2150 | 2150 | | |
| 2151 | + | |
2151 | 2152 | | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
2152 | 2156 | | |
2153 | 2157 | | |
2154 | 2158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2148 | 2148 | | |
2149 | 2149 | | |
2150 | 2150 | | |
| 2151 | + | |
2151 | 2152 | | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
2152 | 2156 | | |
2153 | 2157 | | |
2154 | 2158 | | |
| |||
0 commit comments