js-visualizer-9000-client icon indicating copy to clipboard operation
js-visualizer-9000-client copied to clipboard

setTimeout and Task Queue

Open demimurych opened this issue 1 year ago • 1 comments

The callback function of setTimeout doesn't immediately enter the Task Queue. It only does so after the timer expires. However, in a web interface, this happens instantly, which is an error.

demimurych avatar Jun 14 '24 04:06 demimurych

Good catch.

https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers Says

  • Set task's timer nesting level to nesting level.

  • Let completionStep be an algorithm step which queues a global task on the timer task source given global to run task.

  • Run steps after a timeout given global, "setTimeout/setInterval", timeout, completionStep, and id.

I think what would be nice to have here is visualisation for map of active timers https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#map-of-active-timers

stepancar avatar Jun 26 '24 21:06 stepancar