This is a problem we've thought a lot about with Pyret, and have different concrete solutions. Rather than use heuristics that turn long-running computations into errors, we capture continuations and yield to the browser periodically. This allows long-running computations to eventually complete, while allowing the user to fully interact with buttons and the page while it's happening. This generalizes to nice abstractions for functional event loops and ways to manage asynchronous APIs for novices.
The Doppio JVM and the Whalesong compiler for Racket have similar underlying approaches.
It's quite a bit of effort to work around this inherent limitation of the browser's evaluation model for web-based IDEs!