Skip to content

Bug: devtools Profiler causes unexpected errors #19911

Closed
@henryqdineen

Description

@henryqdineen

We noticed that our app would behave differently during profiling runs and trigger errors. I'm not totally sure what the underlying issue is but I was able to put together a example app to reproduce. As far as I can tell it has to do with how devtools is overriding console.warn and console.error. In that case describeNativeComponentFrame() will call a function component with no args. This works fine as the error is caught in describeNativeComponentFrame() but in it looks like a useEffect() that accesses those props is still triggered and it does not expect props to be undefined.

I realize that having props in the dependencies array of the useEffect doesn't really make sense but I still think it probably shouldn't error.

React version: 16.13.1
React devtools version: 4.8.2

Steps To Reproduce

  1. Open link to code example below
  2. Click "Open In New Window" from the "Browser" tab
  3. Observe a simple app with only <h1>Hello World</h1>
  4. Open the React devtools Profiler tab
  5. Click "Reload and start profiling"
  6. Observe an error Uncaught TypeError: Cannot read property 'foo' of undefined

Link to code example:

https://codesandbox.io/s/cool-sun-wdrry

The current behavior

wdrry csb app_

The expected behavior

The app should work as it while not profile. It should render a <h1>Hello World</h1>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions