react: DevTools crashes (`levelChildren` is undefined) when selecting a component in Flamegraph view

Do you want to request a feature or report a bug? Bug

What is the current behavior? React DevTools crashes in the code below because levelChildren is undefined.

https://github.com/facebook/react/blob/7dc9745427046d462506e9788878ba389e176b8a/packages/react-debug-tools/src/ReactDebugHooks.js#L456-L462

callstack is:

backend.js:formatted:6593 Uncaught TypeError: Cannot read property 'push' of undefined
    at S (backend.js:formatted:6593)
    at _ (backend.js:formatted:6638)
    at inspectHooksOfFiber (backend.js:formatted:6682)
    at rt (backend.js:formatted:2372)
    at Object.inspectElement (backend.js:formatted:2753)
    at t.<anonymous> (backend.js:formatted:3484)
    at t.r.emit (backend.js:formatted:978)
    at backend.js:formatted:7407
    at t (backend.js:formatted:4954)

I haven’t been able to reproduce this yet outside my app, but here’s the steps that trigger the crash in my app:

  1. open dev tools
  2. start profiling
  3. stop profiling
  4. select the CalendarMiddle component in the Flamegraph view
  5. crash!

What is the expected behavior? no crash

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? I’m running:

  • React 16.12
  • RDT 4.2.1 (11/27/2019) revision 3816ae7c3
  • Chrome 79.0.3945.88 (Official Build) (64-bit)
  • MacOS Catalina 10.15.2 (19C57)

I’ve never seen this crash before today. Interestingly, the crash only happens when I select some components in the flamegraph, but doesn’t happen when I select other components. I haven’t figured out the pattern yet of which components will trigger a crash.

I know that this repro isn’t particularly actionable at this point, but I’m hoping that someone who knows the RDT code better than I do might have an idea about why this might be happening.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 18 (11 by maintainers)

Most upvoted comments

Thanks for the repro info.

Even if this crash is caused by why-did-you-render, the crash callstack is all Dev Tools, which will probably make you an issue magnet next time some other package figures out a way to make devtools crash.

Perhaps! I think this is a pretty unique situation though. Hot-patching React APIs is not something we encourage because it can break things (like DevTools). It’s hard to write code that can withstand parts of it being overridden in unexpected ways 😄I’ll keep this in mind and reevaluate if it comes up again though!

Thanks for the follow up @justingrant and the quick fix @vzaidman! I’m going to close this issue because I don’t think DevTools needs to make any changes at the moment in response to this issue.

fixed on version 3.5 of @welldone-software/why-did-you-render

Cool, thanks for the update!

I’ll leave this issue open for now too until we can track down the cause. Please keep me posted.