Infinite Loop
Key point
Repl.it introduced output rate limiting and a JavaScript code transformation technique to solve the problem of browsers freezing due to infinite loops.
Details
Repl.it adopted a design that does not impose time limits on user programs, in order to support complex programs or game implementations. However, this led to two major issues where the browser freezes when an infinite loop occurs.
The first is the browser locking up due to excessive output data. To solve this, they set the pty (pseudo-terminal) to raw i/o mode and introduced a ticker in the frontend server written in Go to limit the output rate to 20 times per second.
The second is the browser freezing when running JavaScript. Since JavaScript runs on the same single thread as the UI, an infinite loop causes the entire browser to freeze. There is a method using Web Worker, but this has the limitation of restricted access to browser APIs.
Therefore, Repl.it protects users by using a Transformation method that adds a counter to JavaScript code to check the number of iterations, along with various Heuristics.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.