Scheduler API (scheduler.postTask)
debt(d7/e3/b3/t8)
Closest to 'only careful code review or runtime testing' (d7). The detection_hints show no automated tooling available; absence of feature detection only surfaces at runtime in unsupported browsers (Firefox/Safari as of 2026). No linter or SAST catches missing fallbacks by default.
Closest to 'simple parameterised fix' (e3). The quick_fix is straightforward: add feature detection + setTimeout fallback + proper priority labels. This is a localised pattern fix within a single scheduling call site, though may need to be applied across multiple call sites if the codebase uses scheduler.postTask widely.
Closest to 'localised tax' (b3). The choice to adopt scheduler.postTask imposes a maintenance burden only on components that use it—they must consistently feature-detect and provide fallbacks. The wider codebase is unaffected. However, if scheduler.postTask becomes widespread, this burden multiplies across many work streams.
Closest to 'serious trap' (t7). The misconception directly contradicts developer expectations: 'widely supported' is false (Chrome-only in 2026). The obvious approach of using scheduler.postTask without feature detection appears to work in development (Chrome) but silently fails in production on Firefox/Safari, a catastrophic silent failure pattern. Score 8 rather than 9 because the failure is not *always* wrong—it's wrong in unsupported browsers, not universally.
TL;DR
Explanation
scheduler.postTask(callback, { priority }) queues a task with explicit priority: 'user-blocking' (highest, for critical UI), 'user-visible' (default, for rendering work), 'background' (lowest, for analytics/precompute). Returns a Promise. Tasks can be aborted with AbortController. Compared to setTimeout(fn, 0): postTask gives the browser scheduling hints, allows prioritisation, and is cancellable. Supported in Chrome 94+, limited elsewhere. Polyfill: scheduler-polyfill. Useful for long tasks that need to yield without losing priority control.
Common Misconception
Why It Matters
Common Mistakes
- Not feature-detecting — crashes in Firefox/Safari.
- Using 'user-blocking' for non-critical work — defeats the purpose.
- Not providing AbortController for cancellable tasks.
Code Examples
// No priority — all setTimeout tasks are equal:
setTimeout(renderUI, 0);
setTimeout(loadAnalytics, 0);
if ('scheduler' in globalThis) {
scheduler.postTask(renderUI, { priority: 'user-blocking' });
scheduler.postTask(loadAnalytics, { priority: 'background' });
} else {
// Fallback:
setTimeout(renderUI, 0);
setTimeout(loadAnalytics, 200);
}