I think it would be really useful to have a jsrun backed setTimeout and friends available somehow. (setTimeout/clearTimeout/setInterval/clearInterval)
Right now I had to hand-roll setTimeout/setInterval myself in JS using Atomics.waitAsync, which works but looks cumbersome to me.
I noticed that python_extension()'s JS bridge (src/runtime/ops.rs:278) does this:
const { ops } = Deno.core;
delete globalThis.Deno;
So it throws away queueUserTimer/cancelTimer along with everything else on Deno.core.
The timer machinery is already running inside jsrun, just out of reach.
Also noticed runner.rs already imports deno_core::stats and calls js_runtime.runtime_activity_stats_factory() to count active timers/intervals for the stats API — so you're already reaching into this exact subsystem from Rust.
Would it be reasonable to just grab the timer functions before the delete and make them available?
Perhaps something like:
const { ops, queueUserTimer, cancelTimer } = Deno.core;
globalThis.__jsrunTimers = Object.freeze({ queueUserTimer, cancelTimer });
delete globalThis.Deno;
Thanks for the great project! I'm already putting it to good use.
I think it would be really useful to have a jsrun backed
setTimeoutand friends available somehow. (setTimeout/clearTimeout/setInterval/clearInterval)Right now I had to hand-roll
setTimeout/setIntervalmyself in JS usingAtomics.waitAsync, which works but looks cumbersome to me.I noticed that
python_extension()'s JS bridge (src/runtime/ops.rs:278) does this:So it throws away
queueUserTimer/cancelTimeralong with everything else onDeno.core.The timer machinery is already running inside jsrun, just out of reach.
Also noticed
runner.rsalready importsdeno_core::statsand callsjs_runtime.runtime_activity_stats_factory()to count active timers/intervals for the stats API — so you're already reaching into this exact subsystem from Rust.Would it be reasonable to just grab the timer functions before the delete and make them available?
Perhaps something like:
Thanks for the great project! I'm already putting it to good use.