How to fully recover a playground that is stuck in an infinite loop (Chrome)?

Hi everyone,

OMG. I have been working on some code in the playground. I almost had just lost some hours of work because of a really stupid mistake that got me stuck in an infnite while-loop :man_facepalming:

Credits to this guy. But I do believe this is definitely worth sharing here too:

  1. Open DevTools
  2. Open the Sources panel
  3. Click Pause. The button changes to Resume Script Execution.
  4. Click and hold Resume Script Execution. Then choose Stop Current JavaScript Call. It is the little square in the drop-down.

Phew…

Best wishes
Joe

4 Likes

This has happened to me a lot of times and unfortunately I was never able to open the dev tools (maybe it’s MacOS specific). It would be pretty cool to save the PG to localstorage before it is executed so in such cases it can be restored manually.

Thanks for the tip anyway! :+1::saluting_face: I bet it will save somene’s bacon for sure :see_no_evil_monkey::smiling_face_with_sunglasses:

4 Likes

If I open DevTools in advance, it works, but
when I open DevTools during an infinite loop, it doesn’t change from pause to Resume Script Execution.
in case window chrome (About the Lost PG :smiling_face_with_tear:)

1 Like

@Deltakosh I’ll create a PR if you guys are OK with this.

Regarding the PG GUI:

  1. add a checkbox to toggle storing the code (default ON), placed here:
  2. maybe set the limit how many PGs can be stored (LIFO), defaulting to 20? Since this would be used just for recovery, maybe we don’t even need this input and we could hardcode this value.

Restoring the PG would be done manually. (docs)
We can upgrade the GUI later – to be nicer :smiley: to the programmers and give them a more user friendly tool to browse/restore the stored PGs.

I’d like to add that I know about your policy to not store anything (or only the absolute minimum) in the user’s browser storage. This is an edge/emergency case and needs to be really considered to make an exception from this rule.

4 Likes

I think I have deeply internalized not programming in the playground from past mishaps.

1 Like