miniflare
miniflare copied to clipboard
Second request to a DO hangs if installing default Sinon.js fake timer
If I install Sinon.JS fake timer as follows:
fakeClock = FakeTimers.install({
toFake: ['setImmediate']
})
fakeClock.setSystemTime(1643948235000)
the second request to a DO seems to hang. Since setImmediate is by default hijacked when FakeTimers.install is invoked without arguments this is a problem. Spelunking through the code, it seems like setImmediate is used for DO I/O gates which seems like a likely explanation as to why that happens. Maybe using queueMicrotask and capturing the value in the global scope might avoid problems with fake timers?
Hey! 👋 Yep, that seems like the problem. I wonder if importing setImmediate directly from the timers built-in module gives you a unmocked version? Could use that instead... 🤔