Languages
[Edit]
EN

Google Chrome - stop infinite loop in JavaScript debug

20 points
Created by:
Aleena
694

Using Google Chrome, there are few ways to stop JavaScript debugging.

Google Chrome 67 introduced some feature that lets to stop infinity loops without closing the current tab (source here).

Quick solution:

Pause and stop infinity loop in Google Chrome DevTools.
Pause and stop infinity loop in Google Chrome DevTools.

In the below sections, you will find more detailed descriptions with different approaches to stopping the infinite loops.

1. Stop button in Chrome DevTools example

Note: to use this approach, DevTools should be turned on before infinite JavaScript code will be executed. In other case, we will be not able to open the tools with F12 because of Google Chrome window freeze. It will be still possible to turn on the tools with browser menu, but tools will not get connection with executed source code to stop it - in this case code executing can be stopped only via closing tab or window. Sometimes for small amount of RAM or big amount of opened tabs DevTools can have problem to stop infinity script.

Steps:

  1. open Chrome DevTools with F12, Ctrl+Shift+i or from menu Main menuMore toolsDeveloper tools,
  2. open Sources tab,
  3. goto webpage that you want to debug,
  4. run some code that has infinity loop,
  5. click Chrome DevTools window to get focus on it,
  6. pause script with F8, Ctrl+\ or by clicking Pause script execution button (check 3rd step on the second screenshot),
  7. hold pressed mouse button for 1-3 seconds on the button again to see more options,
  8. move click action to square stop button on the expanded menu to stop permanently script execution.
Explanation, how to open Google Chrome DevTools from menu.
Explanation, how to open Google Chrome DevTools from menu.

 

Explanation, how to pause infinity JavaScript loop using Google Chrome DevTools.
Explanation, how to pause infinity JavaScript loop using Google Chrome DevTools.

 

Explanation, how to stop JavaScript loop using Google Chrome DevTools.
Explanation, how to stop JavaScript loop using Google Chrome DevTools.

2. End process by closing tab or window example

Use close button near the webpage tab to stop the process. If it does not help use Task manager described in the next approach of this post.

3. End process button in Task manager example 

Steps:

  1. open Chrome Task manager with Shift+Esc or from menu Main menuMore toolsTask manager,
  2. find process on list by tab name or biggest CPU load (use column sort option),
  3. select process and click End process button.

References

Alternative titles

  1. Google Chrome - how to break JavaScript code executing / debugging?
  2. Google Chrome - how to stop JavaScript code executing / debugging?
  3. Google Chrome - stop infinite loop DevTools
  4. Google Chrome - pause infinite JavaScript loop
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join