Infinite loop + refresh making code unrecoverable


#1

By writing an infinite loop in your code and refreshing the page, it’s possible to lose your work.

Tested in Firefox and Chrome on Windows 8, within the multiplayer Dungeon Arena level.

Steps to reproduce:

  1. Create some code with an infinite loop (or that just runs for too long).
  2. Cast it. You should get a notice saying that your code probably has an infinite loop.
  3. Refresh the page. You should, shortly after the loading bar gets to “Ready”, receive the “Infinite Loop Detected” pop-up. This gives you the “Try Again” and “Reset Level” options. “Try Again” gets the same pop-up, and “Reset Level” naturally destroys your work.

This is an issue as a single bug in the user’s code can erase potentially a lot of work.

Possible solutions:

  1. Don’t run the user’s code on level load, and instead wait for the user to cast or hit play to run it the first time. Then, the user could fix the infinite loop. Added bonus of reducing load times probably pretty significantly.
  2. Add another option to the “Infinite Loop Detected” pop-up, letting you open the level (without running the user’s code) to fix the infinite loop.

Are there any workarounds for this currently?

Edit: found a workaround in at least one case. My code was merely running slowly rather than looping infinitely, and selecting a different opponent for whatever reason made it pass the timeout check. This probably doesn’t help for true infinite loops or for non-multiplayer levels, though.


#2

Sorry about that, @googlyeyesultra! It’s the most frustrating thing ever to lose code. I’m tracking this bug in an issue over here on GitHub: https://github.com/codecombat/codecombat/issues/488

I think the best solution would be to comment out the player’s code when this happens and then run the level as if the function does nothing (which is what we do for other kinds of programming errors). Will take some doing, though.

Better version control for player code would also go a long way toward making this suck less when it does happen, too.


#3

Any luck on this? I don’t want to reset my code on gridmancer cause I was so close to solving it. Will this be solved soon?


#4

@coaster_maniac5 what’s your CodeCombat username? I’ll recover it for you.


#5

This should be fixed now, insofar as there’s an option to “Comment Out My Code” which should allow you to recover it.


#6

This just happended to me in the multiplayer dungeon. (Press reset on infinite loop alert)

@nick Could you please recover my code for ogres?

Thanks a lot


#7

Sure, I’ve recovered it. Don’t press the “Reset” button if you can help it, though, because there won’t always be able to recover the code, since we haven’t implemented a versioning / diff system for your code yet.