Claude Opus 5.5

vitest-5-0-0-15-b

Claude Code's read-only tools, web search on, ludion sync on

Question

Can expect.poll hang my Vitest test forever if the callback never settles?

Answer key

A correct answer says
expect.poll fails when the polled function does not resolve within the timeout.
The stale answer
expect.poll keeps waiting on a function that never resolves.

Answer

**Not forever, as long as you keep a test timeout.** The test will still fail, but `expect.poll`'s own `timeout` probably isn't what stops it.

- **Why the poll timeout may not fire:** I'm going from my memory of Vitest's source and didn't check it against 5.0.3. As I recall, `expect.poll` awaits your callback on every attempt. When its `timeout` (default 1000 ms) runs out, it makes one last attempt and awaits that too. If your callback returns a promise that never settles, the poll may never resolve or reject.
- **What actually stops it:** the test-level timeout (`testTimeout`, default 5000 ms) still applies and fails the test with a timeout error. It only really hangs forever if you set `testTimeout: 0` or pass a timeout of 0 to that test.
- **How to protect yourself:** make the callback itself time-bounded, for example by wrapping the inner call in `Promise.race` with a short timeout or using an `AbortSignal`. Also always `await expect.poll(...)`. An un-awaited poll can let the test finish early or surface failures in the wrong place.

Answering cost $0.09.

Grade

wrong

The judge's reason: It claims expect.poll's own timeout may never fire on a never-settling callback (stale behavior), whereas the key says expect.poll now rejects when the callback doesn't settle within the timeout.

The judge's log

Session log

What the agent wrote, the tools it called, and what they returned, from docs/bench/2026-10-11-done3/runs/B-project-sync/vitest-5-0-0-15-b.jsonl. Thinking and the session's settings are left out. The raw log

  1. Agent

    **Not forever, as long as you keep a test timeout.** The test will still fail, but `expect.poll`'s own `timeout` probably isn't what stops it.
    
    - **Why the poll timeout may not fire:** I'm going from my memory of Vitest's source and didn't check it against 5.0.3. As I recall, `expect.poll` awaits your callback on every attempt. When its `timeout` (default 1000 ms) runs out, it makes one last attempt and awaits that too. If your callback returns a promise that never settles, the poll may never resolve or reject.
    - **What actually stops it:** the test-level timeout (`testTimeout`, default 5000 ms) still applies and fails the test with a timeout error. It only really hangs forever if you set `testTimeout: 0` or pass a timeout of 0 to that test.
    - **How to protect yourself:** make the callback itself time-bounded, for example by wrapping the inner call in `Promise.race` with a short timeout or using an `AbortSignal`. Also always `await expect.poll(...)`. An un-awaited poll can let the test finish early or surface failures in the wrong place.