> I agree with the problems but am curious how you would solve the non-terminating code problem?
I thought it was running on the browser, based on what the OP said, so that would entail opcode-counting or, if you can use multiple threads, watchdog timers. That is, don't try to solve the halting problem, just enforce an arbitrary limit to how long code can run.
However, if the code is being run on the server, you could enforce CPU and RAM quotas to do the same thing with the OS's help.