I'd like to find a more graceful way of handling this. Any suggestions?
http://github.com/johang88/haskellinjavascript
;)
This is convoluted and fragile, but if I wanted to roll out "sandboxes" on limited hardware I'd start with something like this.
Here's an approach that's a variation/refinement of my current one: Instead of just orphaning old clients when their sandboxes get GC'd, leave them with a local copy of their REPL history. If they try to use the REPL again after a long period of silence, a new sandbox will be allocated for them (as it would be for a fresh client), and all the commands in their REPL history loaded in to bring it back to its previous state.
This approach could potentially pave the way for users having persistent REPLs, even across page reloads.