Skip to content

Bug: Infinite iterator in props causes crash in react-dev-tools #19660

Closed
@mizukami234

Description

@mizukami234

React version: Any
React Developer Tools: 4.8.2

Steps To Reproduce

  1. create and render a Component which contains infinite iterator
function* makeCounter() {
  let c = 0;
  while (true) {
    yield c++;
  }
}
const counter = makeCounter();

const Sample = () => <Component counter={counter} />;
  1. open chrome devtools and select this component with React Dev Tools (Components tab)

  2. crashes after few seconds

Link to code example:

https://codesandbox.io/s/happy-lake-c1vyf?file=/src/App.js

The current behavior

The page crashes due to devtools crash.

The expected behavior

devtools doesn't crash.

This is because ReactDevTools is trying to display elements inside iterator object with transforming it into array here:

const array = Array.from(data);

Iterators could be generally infinite (and also have side effect, like counter in the example). So I think it should not be extracted to array here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions