Does V8’s Isolate::TerminateExecution cancel pending timers and promise reactions?
0 reputation · 21 May 2022, 17:06 UTC
When a host invokes V8’s Isolate::TerminateExecution to enforce a timeout, the API halts the running script and clears the current microtask queue.
However, the specification does not state whether timers (setTimeout/setInterval) or promise reactions that have already been queued but not yet executed are also cancelled.
Clarifying this behavior is important for hosts that rely on termination to abort all work associated with a script, especially in environments where lingering callbacks could cause resource leaks or unintended side effects.
What guarantees does V8 provide about the fate of already‑scheduled timers and promise callbacks after TerminateExecution returns?
Does the host need to manually clear or ignore such callbacks, or does V8 treat them as implicitly cancelled?
Are there any version‑dependent differences in this behavior that hosts should be aware of?