I have some JavaScript that, I believe, is stuck in an infinite loop. I know I can just reload the page, but I have data in a form on the current page that I'd like to keep. The tab is completely unresponsive, so I can't just copy and paste everything and then reload. So is there any way to kill the javascript thread, but keep the DOM in Chrome?
-
1"Is there any way to kill the javascript thread, but keep the DOM in Chrome?" Nope. You just got to fix your infinite loop.Mike Cluck– Mike Cluck2016-10-24 19:59:40 +00:00Commented Oct 24, 2016 at 19:59
-
After thirty seconds Chrome gives you the chance to stop the executing script. You can recover the information then.BCartolo– BCartolo2016-10-24 20:00:38 +00:00Commented Oct 24, 2016 at 20:00
-
Here's the painful issue... The infinite loop is in a codepen.io pen. So if I reload, I lose a lot of the code that actually caused the infinite loop.bigblind– bigblind2016-10-24 20:01:14 +00:00Commented Oct 24, 2016 at 20:01
-
As @BCartolo mentioned, you should get a prompt to kill it. If not, I guess take a screen shot and capture as much of the code as you can...dmeglio– dmeglio2016-10-24 20:02:03 +00:00Commented Oct 24, 2016 at 20:02
-
If you are writing lots of things on the web it's a good idea to use this extension: chrome.google.com/webstore/detail/lazarus-form-recovery/…BCartolo– BCartolo2016-10-24 20:03:51 +00:00Commented Oct 24, 2016 at 20:03
|
Show 1 more comment
3 Answers
2 Comments
Derek 朕會功夫
You can't stop the script, but you can pause it and inspect the DOM.
niutech
@Derek朕會功夫 You can stop the script - just click on the Pause button, then click-and-hold on the Play button and choose Stop from the drop-down menu.
Open chrome developer tools and go to the sources tab. On the right panel press "pause script execution".
2 Comments
niutech
Then click-and-hold on the Play button and choose Stop from the drop-down menu in order to stop the script execution.
user3560827
@nuitech - how do you click Stop when mouse is already on click-and-hold, the moment you release it to stop the execution it doesn't work, why is there no stop button, i mean really now?
looks like someone had the same problem
Cancel infinite loop execution in jsfiddle
Answer:
With the developer mode, go into resources and find your script and copy and paste it into a text document or a new window. If you can't find it in resources, do a search for a variable or line of code you used.

