Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useState's setState hangs when called in closed window #16585

Closed
aaronjensen opened this issue Aug 27, 2019 · 4 comments · Fixed by #19220
Closed

useState's setState hangs when called in closed window #16585

aaronjensen opened this issue Aug 27, 2019 · 4 comments · Fixed by #19220

Comments

@aaronjensen
Copy link

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

Bug

What is the current behavior?

If useState's setState is called in a closed window, it hangs the browser (at least Chrome). I agree that this seems like a weird issue, but we do this all of the time in our plugin we've built for an application that has iframe based UI.

This reproduces it. Just click "Do it". Note that your codesandbox service worker will spin up to 100% cpu and I can't figure out a way to stop it other than to kill that task in the Chrome task manager

https://codesandbox.io/s/react-setstate-on-hidden-window-hangs-repro-cixqn

What is the expected behavior?

No hang, it should just ignore the setState call, ideally.

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

16.9. I'm not sure, but hooks are fairly new. This reproduces in Chrome 76, but not Firefox as far as I can tell.

@zachary-nguyen
Copy link

zachary-nguyen commented Sep 13, 2019

I can confirm that the service worker indeed hits 100% cpu and hangs the page. Will take a look into this :)

Could this be similar to the bug encountered here: #16734

@aaronjensen
Copy link
Author

FYI this still repros on 16.12.0.

@gaearon
Copy link
Collaborator

gaearon commented Jun 30, 2020

#19220

@aaronjensen
Copy link
Author

Thank you, @gaearon ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants