question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: DevTools calls arbitrary generators which may be stateful

See original GitHub issue
function foo*() {
  yield 1;
  yield 2;
}

let gen = foo()

Currently if you put gen into state or props and then open this component in DevTools, it will consume that generator while trying to format it. So gen.next() will give you { done: true } next time you call it.

This happens here:

https://github.com/facebook/react/blob/60ba723bf78b9a28f60dce854e88e206fab52301/packages/react-devtools-shared/src/utils.js#L616-L623

I think that maybe we should treat iterables differently if they return themselves as an iterator. Since that means they’re likely stateful and it’s not ok to iterate over them.

We detect iterables here (DevTools terminology is wrong btw, it should be iterable rather than iterator):

https://github.com/facebook/react/blob/60ba723bf78b9a28f60dce854e88e206fab52301/packages/react-devtools-shared/src/utils.js#L438-L439

I think maybe we could split this into iterable and opaque_iterable, and make sure none of the codepaths attempt to traverse opaque_iterable or pass it to something that would consume it (e.g. Array.from).

We could detect it based on data[Symbol.iterator]() === data — that clearly signals the iterable is its own iterator (which is the case for generators), and therefore it’s not OK for DevTools to consume it.

Maybe some other heuristic could work. But overall, the goal is that Map and friends is still being iterated over, but an arbitrary generator is not.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
todortotevcommented, Sep 10, 2020

Just a note, I’m nearly done! Sorry for being slow it just was my first attempt!

1reaction
todortotevcommented, Aug 30, 2020

@gaearon I could give a shot on this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ludwig-lang - npm Package Health Analysis | Snyk
You can connect your project's repository to Snyk to stay up to date on security ... The generator may call the consumer an...
Read more >
Databricks Runtime 12.0 (Beta) - Azure Databricks | Microsoft Learn
You can now selectively overwrite data matching an arbitrary expression in a Delta table ... Migrate type check failures of generators onto error...
Read more >
react class component property does not exist on type
Error with Redux DevTools Extension using TS: "Property '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__' does not exist on type 'Window'."? TypeScript speeds up your ...
Read more >
Security Bulletin 02 Nov 2022
CVE Number Base Score Reference CVE‑2021‑32679 8.8 https://nvd.nist.gov/vuln/detail/CVE‑2021‑32679 CVE‑2021‑32688 8.8 https://nvd.nist.gov/vuln/detail/CVE‑2021‑32688 CVE‑2021‑32765 8.8 https://nvd.nist.gov/vuln/detail/CVE‑2021‑32765
Read more >
Fix list for IBM WebSphere Application Server V8.5
Web Services (for example: SOAP or UDDI or WSGW or WSIF), PH26629, Error may occur when calling ServiceDelegate.releaseService() SPI in client application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found