The following code works as expected in v0.25.1, but fails with an error in v0.26.0:
import { getQuickJS } from 'quickjs-emscripten';
function assert(predicate: boolean, message: string) {
if (!predicate) {
throw new Error(message);
}
}
async function sanityTest() {
// Initialize a runtime & context
const QuickJS = await getQuickJS();
const runtime = QuickJS.newRuntime();
const context = runtime.newContext();
// Inject a global tracer() function to track executions
let executed = false;
const tracer = context.newFunction('tracer', () => {
executed = true;
return context.undefined;
});
context.setProp(context.global, 'tracer', tracer);
tracer.dispose();
// Evaluate some code that schedules a pending job
context.evalCode('Promise.resolve(true).then(() => tracer())');
// Verify our trace log hasn't been executed yet
assert(!executed, 'tracer executed synchronously!');
// Run pending jobs
runtime.executePendingJobs();
// Verify our trace log has been executed
assert(executed, 'tracer not executed after executePendingJobs');
}
sanityTest();
The error I get when running in v0.26.0 is:
TypeError: Object not disposable
at j (chunk-CH72DI2V.mjs?v=b51f19f5:1:347)
at M.executePendingJobs (chunk-CH72DI2V.mjs?v=b51f19f5:5:3444)
at sanityTest (sanity-test.ts?t=1704396176446:20:11)
I'm assuming this has to do with the using/dispose support added in 0.26.0, which may not be added to the intrinsic Promise.resolve() return value in the context?
The following code works as expected in v0.25.1, but fails with an error in v0.26.0:
The error I get when running in v0.26.0 is:
I'm assuming this has to do with the using/dispose support added in 0.26.0, which may not be added to the intrinsic
Promise.resolve()return value in the context?