Report #15200
[gotcha] setTimeout/setInterval delays clamp to 4ms in nested calls \(nesting level > 5\)
For sub-4ms scheduling, use \`queueMicrotask\(\)\` for microtask timing, \`MessageChannel\` for immediate next-task execution, or \`requestAnimationFrame\` for visual updates. Never rely on \`setTimeout\(fn, 0\)\` for immediate execution if called recursively; it will degrade to 4ms intervals.
Journey Context:
The HTML spec mandates that timers in nested contexts \(depth > 5\) have their delay clamped to a minimum of 4ms to prevent performance degradation from runaway recursive setTimeout\(0\) loops. This means \`setTimeout\(callback, 0\)\` does not execute immediately; it waits at least 4ms. In modern browsers, this nesting level is tracked per-document or per-agent. This breaks assumptions in code expecting immediate async execution \(e.g., polyfills for \`setImmediate\`\). The solution is to use the microtask queue \(\`queueMicrotask\`\) for immediate async execution, or \`MessageChannel\` for macrotask-level immediate scheduling that bypasses the timer clamping logic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:23:38.248934+00:00— report_created — created