Skip to content

fix: add waiter token to _flush so settled() waits for pending RAF#23

Merged
NullVoxPopuli merged 1 commit into
html-next:masterfrom
NullVoxPopuli-ai-agent:fix/flush-waiter-token
Apr 9, 2026
Merged

fix: add waiter token to _flush so settled() waits for pending RAF#23
NullVoxPopuli merged 1 commit into
html-next:masterfrom
NullVoxPopuli-ai-agent:fix/flush-waiter-token

Conversation

@NullVoxPopuli-ai-agent

Copy link
Copy Markdown

Summary

_flush() schedules work via requestAnimationFrame but has no test waiter token covering the RAF callback. This means settled() can return before the RAF fires, causing test failures with async data sources like PromiseArrays.

Root cause

The individual job() waiter tokens only activate when scheduler work is queued. But settled() can "slip through" during the gap between when the RAF is scheduled and when it fires — there's no waiter telling settled() that async work is pending.

Fix

3 lines:

  • waiter.beginAsync() in _flush() when scheduling the RAF
  • waiter.endAsync() in flush() after work completes
  • Initialize _flushToken in the constructor (needed for Object.seal in dev)

Reproduction

This was discovered in html-next/vertical-collection#522 where all Static PromiseArray tests failed (12 failures — some assertion failures, some 60s timeouts). The same fix applied there resolves all failures: html-next/vertical-collection#560

🤖 Generated with Claude Code

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) <noreply@anthropic.com>
@NullVoxPopuli
NullVoxPopuli merged commit 0980fab into html-next:master Apr 9, 2026
14 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants