From f12b7c5970e6af8b1a0a60db69e2cd4a0501b308 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 9 Apr 2026 18:17:48 -0400 Subject: [PATCH] fix: add waiter token to _flush so settled() waits for pending RAF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this, settled() can return before a pending requestAnimationFrame callback fires. This causes test failures with async data sources like PromiseArrays — settled() finds no active waiter tokens during the gap between render and promise resolution, so it returns early before items are available. The fix adds waiter.beginAsync() when scheduling the RAF in _flush(), and waiter.endAsync() in flush() after all queued work completes. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.js b/src/index.js index ba027f6..72e7020 100644 --- a/src/index.js +++ b/src/index.js @@ -46,6 +46,7 @@ export class Scheduler { this.affect = []; this.jobs = 0; this._nextFlush = null; + this._flushToken = null; this.ticks = 0; if (macroCondition(isDevelopingApp())) { @@ -80,6 +81,7 @@ export class Scheduler { return; } + this._flushToken = waiter.beginAsync(); this._nextFlush = requestAnimationFrame(() => { this.flush(); }); @@ -128,6 +130,7 @@ export class Scheduler { } this._nextFlush = null; + waiter.endAsync(this._flushToken); if (this.jobs > 0) { this._flush(); }