Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel infinite loop execution in jsfiddle

When you get an infinite loop in jsfiddle in Chrome, your only choice (that I know of) is to close the tab. Of course, this means you lose all your work in the current window! Is there an easy way to stop an infinitely executing script?

  1. I have the developer tools open because I was doing some debugging.
  2. I am able to pause the script and step through the loop.
  3. I can't find anywhere to stop the script.
  4. I can't modify the script or variables to stop the infinite loop (because the script execution occurs in an iframe on a separate domain, so modifying data in the iframe with JavaScript is not allowed and generates an Exception in the console).

It all started because I decided to swap directions on my loop from

for (var c = 0; c <= 11; c++) 

to

for (var c = 12; c > 0; c++) 

But as you can see above, I forgot to change it from c++ to c--.

Any ideas?? I still have the tab open and I'm hoping to get it back without closing the tab :-)

like image 685
mellamokb Avatar asked Sep 30 '11 21:09

mellamokb


People also ask

How do you break an infinite loop?

One way of breaking the infinite loop is to throw an unhandled exception, which will stop the execution of current call stack. To do so: worked for me. I haven't tried, but I believe that by overloading getter or setter you can use the trick described above also for assignments and reads, not only for function calls.

How do I stop an infinite loop in Linux terminal?

Try Ctrl+D. If that doesn’t work then open a new terminal and ps aux | grep command where command is the name of the script you wrote and then kill the pid that is returned. Show activity on this post. And you just echo 1 > mytestfile , if you want to stop the loop. How do you stop an infinite loop?

How do I stop JSFiddle from loading?

While the page is unresponsive, go to Chrome > Preferences > Privacy and disable JavaScript. Wait for page to die (about 4 or 5 minutes for me); the sad face icon comes up in that tab. Hit the back button. It should look like JSFiddle is loading, but it won't because funnily enough JSFiddle needs JavaScript just to render a page.

How to display JSFiddle results without running the script?

Then I pressed Shift-Escape to launch the Task Manager, kill the JSFiddle process, re-select the tab, and hit the back button to display the page without running the script. JSFiddle loads the "result" panel using an iframe. As of June 2016, the URL for the frame is the Fiddle URL plus "/show/".


1 Answers

How to do it without Developer Mode:

  • Open a new tab
  • Open the Task Manager with Shift-Escape
  • Kill task
  • Use back button for the killed tab (JSFiddle won't run the script)
  • Fix bug
  • Update

Or on MacOS,

  • Open Activity Monitor
  • Kill the first "Google Chrome Helper (Renderer)" process. It's probably JSFiddle
  • Fix the issue
  • Run the code
like image 93
Adam Ritter Avatar answered Sep 19 '22 15:09

Adam Ritter