codesandbox-client icon indicating copy to clipboard operation
codesandbox-client copied to clipboard

App is unresponsive/crashes when an infinite loop is called with a console.log (take 2)

Open steinybot opened this issue 3 years ago • 1 comments
trafficstars

🐛 bug report

Preflight Checklist

  • [x] I have read the Contributing Guidelines for this project.
  • [x] I agree to follow the Code of Conduct that this project adheres to.
  • [x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Description of the problem

Same as https://github.com/codesandbox/codesandbox-client/issues/884

I hit this problem a lot, I am surprised that it isn't a bigger issue. I'm usually using the React Typescript template, I don't know if that is relevant.

When it happens it (usually) completely kills the browser (Chrome). I can't close the tab. Opening codesandbox.io in another tab doesn't load. I have to close the whole application. As soon as I open the afflicted sandbox, boom, it's busted again. I can open the developer tools and pause the script but even with it paused, it doesn't reload. Pretty strange, I thought Chrome would be a bit more resilient to bad scripts than that.

How has this issue affected you? What are you trying to accomplish?

To Reproduce

See example.

It almost always goes something like:

  • I am trying to find a bug
  • I add a console.debug statement
  • Boom

It might be an infinite loop but I can't see it. Usually it is a React app that works fine, it responds to events etc but there is a bug somewhere. If it is a loop then it could be a render loop (calling setState from useEffect) which I know React detects itself even within the sandbox.

It seems like something bigger is going on.

Link to sandbox: link

Your Environment

Software Name/Version
Сodesandbox 506a47198
Browser Version 103.0.5060.134 (Official Build) (arm64)
Operating System MacBook Pro (16-inch, 2021), Apple M1 Max, macOS Monterey version 12.4

steinybot avatar Jul 28 '22 23:07 steinybot

There is a render loop in this example.

If I run the same thing in a parcel project then I get the React warning. It does log infinitely but I can easily close the tab, refresh etc as one would expect.

Codesandbox is definitely exacerbating the problem somehow.

steinybot avatar Jul 29 '22 00:07 steinybot