Skip to content

Add getPromiseState microtask timing tests - #207

Merged
NullVoxPopuli merged 2 commits into
mainfrom
get-promise-state-timing-tests
Oct 14, 2026
Merged

NullVoxPopuli merged 2 commits into
mainfrom
get-promise-state-timing-tests

Conversation

@NullVoxPopuli

@NullVoxPopuli NullVoxPopuli commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Adds tests that read getPromiseState from JS, with no render() or settled(), and record which microtask each property changes on. No behavior changes.

Results

input sync resolved / error set isLoading → false
plain value, sync function, sync throw, settled cache hit settled sync sync
Promise.resolve, async () => value loading microtask 1 microtask 3
Promise.reject loading microtask 2 microtask 3
async fn with one await loading microtask 2 microtask 4
async fn that awaits, then throws loading microtask 3 microtask 4

Nothing changes after a macrotask.

Worth noting: for promises, there's a window of 1–2 microtasks where resolved (or error) is set but isLoading is still true. This happens because the state is updated in a .then().catch().finally() chain, one link per microtask. Templates never show it because they wait for the render loop. JS code that checks isLoading first could see it. These tests pin it down so any fix is deliberate.

How it works: a stepTimeline(state, assert) helper reads the state right after the call, after each of 10 await Promise.resolve()s, and after a setTimeout. Each time the state changes, it calls assert.step, and the test checks the result with assert.verifySteps.

🤖 Generated with Claude Code

Read the state from JS without rendering, and record which microtask
isLoading, error, and resolved change on for each kind of input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
reactive Ready Ready Preview Oct 14, 2026 6:05pm UTC

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NullVoxPopuli
NullVoxPopuli merged commit 3da6f79 into main Oct 14, 2026
34 of 35 checks passed
@NullVoxPopuli
NullVoxPopuli deleted the get-promise-state-timing-tests branch October 14, 2026 18:21

This branch was successfully deployed

1 active deployment
Preview — a56720b1 Deployed Oct 14, 2026 by vercel[bot]
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.

1 participant