If the Run button is double-clicked, the result is:
<no location info>: mkTopLevEnv: not interpreted main:Main
as a compiler error. This may have something to do with non-reentrancy of the GHC API? But at the same time, use of CacheMap should be a guarantee that the GHC API is used synchronously, at least within a single mode. So this needs some more investigation about what's going on.
Fixing the retention for compiles seems to have mitigated this one, but it's still there; it just will require lots of simultaneous submits of different source code to trigger now.
It looks temptingly like a reentrancy bug with the GHC API, but even wrapping the GHC API usage with a global lock doesn't seem to help. At the same time, performance a manual garbage collection directly before calling the GHC API seems to make things worse, sometimes even triggering the bug when there hasn't been a particularly long time since the last use of the GHC API.
Switch to interpreted mode for the compiler. Because we open up the
top-level scope, we need to interpret anyway; so this avoids some effort
and compiler bugs triggered by writing out the compiled versions too.