[DevTools] Throw an error when attempting to clone non-existent node#470
[DevTools] Throw an error when attempting to clone non-existent node#470everettbu wants to merge 1 commit into
Conversation
Greptile OverviewGreptile SummaryThis PR changes The change is localized to the Profiler commit tree reconstruction path ( Confidence Score: 3/5
Important Files Changed
|
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js
Line: 349:353
Comment:
**Wrong operation index**
`TREE_OPERATION_UPDATE_TREE_BASE_DURATION` reads `id` from `operations[i + 1]` and then uses `operations[i + 2]` for the duration, but `i` isn’t advanced until after the update. This is fine, but `id` is assigned without Flow casting (unlike other cases), and more importantly the code currently sets `id = operations[i + 1];` without incrementing `i` first, whereas many other cases rely on `i` pointing at the opcode. If the ops format ever changes (or if `i` got off by one earlier), this throws due to the new clone validation and can take down the Profiler UI. Consider explicitly validating the opcode payload length or using consistent casting like other cases.
How can I resolve this? If you propose a fix, please make it concise. |
|
Upstream PR was closed or merged. Code is synced via branch mirror. |
Mirror of facebook/react#35702
Original author: hoxyq
There is an existing issue with serialisation logic for the traces from Profiler panel.
I've discovered that
TREE_OPERATION_UPDATE_TREE_BASE_DURATIONoperation for some reason appears earlier in a sequence of operations, before theTREE_OPERATION_ADDthat registers the new node. It ends up cloning non-existent node, which just creates an empty object and adds it to the map of nodes.This change only adds additional layer of validation to cloning logic, so we don't swallow the error, if we attempt to clone non-existent node.