sigvef/arktis-tweet-demo

Prevent infinite loop in the code from crashing the whole thing

Closed this issue · 1 comments

This problem occurs while tweaking with the condition parameter in a for loop, for example. Could it be possible to let a worker with a timeout try to run u(t), and if it times out, kill it and don't run the code in the iframe?

It looks like codepen is using some sort of code injection to detect infinite loops, but I don't think that's a good solution for us: http://webcache.googleusercontent.com/search?q=cache:jaHqbi0xLp8J:codepen.io/quezo/post/improving-infinite-loop-detection+&cd=1&hl=no&ct=clnk&gl=us

Instead, I think running the code in a web worker with a short timeout (say 300 ms) is a better idea:
http://blog.namangoel.com/replacing-eval-with-a-web-worker