I'm using quickjs-emscripten to try to evaluate some JS within a Cloudflare Worker (i.e. serverless). I know the pitfalls of JS evaluation and don't need to debate that here.
The docs say this should work:
import { getQuickJS, shouldInterruptAfterDeadline } from "quickjs-emscripten"
getQuickJS().then((QuickJS) => {
console.log('start'); //<-- never happens
const result = QuickJS.evalCode("1 + 1", {
shouldInterrupt: shouldInterruptAfterDeadline(Date.now() + 1000),
memoryLimitBytes: 1024 * 1024,
})
})
...but the callback is never entered and no error is thrown (tried wrapping it in a try-catch).
Anyone idea what could be wrong?
Okay, it's been fun to do a deep dive on this!
You're looking to do a custom WASM loader for the Emscripten.
and then later inside your
addEventListenerI covered my research in a post here.