JavaScript playground (in-browser) infinite loop handling
buckett opened this issue · 2 comments
If I run a script using the in-browser JavaScript playground that results in an infinite loop the page blocks.
while(true){}
I think this is run on the main event loop so the page then becomes unresponsive, if someone is editing an example and accidentally does this (eg makes end condition on their loop incorrect) having the page freeze is not a nice user experience.
Running on the main event loop is easy and works as most people expect, but I wonder if it should run on a web worker instead?
https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API
Sure, I'll give it a try later.
Web workers have no access to the DOM, so I decided not to use them. A simple page refresh solves the infinite loop problem, so I'll leave the current implementation in place for now.