[Suggestion] Infinite loop protection

Hitting an infinite loop when programming is annoying; it takes a while before the browser kicks in and stops the loop, if it does at all, or else the browser will crash and you’ll have to restart it. Either way, it takes a while to get back to programming again, and in the meantime your computer may have overheated if it’s old, or whatever.
My suggestion is to copy CodePen and implement infinite loop protection (two links). I think that if the course detects an infinite loop and breaks it up, it’ll be much less annoying/stessfull/whatever else to a user trying to figure out what’s wrong if a little popup comes up instead, saying something like:

You’ve got an infinite loop in your code, so we stopped your code from running see more on infinite loops here. If you think this is a mistake and that we shouldn’t have stopped your code, you can force run it, but be careful!

Just a suggestion, but I think it would really be very helpful to new users.

Do you want infinite loop protection in Codecademy?

  • Yes, I want infinite loop protection in Codecademy
  • No, I don’t want infinite loop protection in Codecademy
  • I don’t care if Codecademy has infinite loop protection or not

0 voters


One immediate cure would be to turn off auto-refresh in lessons with loop constructs. Only allow the code to run on Submit.


@mtf YES PLEASE, even on non-loop exercises! I don’t like it when my code gets auto-run without my even being asked if that’s what I want to happen, and the method Codecademy is using to run the code seems to jam my computer for just a second, while it reloads the code.

1 Like

I actually don’t support this idea because I believe it’s important for a student to experience the actual consequences of an infinite loop. Why is it bad? What will happen? Experiencing a crashed browser gives them that tangible experience, and it’s a minor inconvenience to them to restart a browser.

Secondly, if they get an ‘oops you typed an infinite loop’ popup when they press run then they’re getting a false affordance - making them less apt to review their own code and understand what it does before they try to run it.

I’m speaking from the experience of a middle school CS teacher teaching JavaScript.


@thedannywahl Good point, infinite loops can help learning. Still, I think having infinite loop protection something you can turn on in your account settings, or at least being able to disable auto-refresh from there, would be really nice.

Agree not having infinite loop protection helps learn the ‘painful’ but safe way.