test(android): bound the screenshot write wait by wall time, not event-loop turns - #3250
Conversation
…t-loop turns The rotation-probe test yielded 1,000 setImmediate turns for the PNG write to finish; a loaded libuv thread pool (Coverage CI) can need more, so the grace timer was not yet installed and the test failed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Size Report
Startup median (7 runs, lower is better):
|
|
PR #3250 is ready at 027701b, and I found nothing that needs a change. CI is green, and I know of no conflicts. I did not run the test locally, and I did not check the installed Vitest version's fake-timer behavior beyond the package.json range. Not blocking: the write deadline at https://github.com/callstack/agent-device/blob/027701b/packages/platform-android/src/__tests__/screenshot.test.ts#L104 is 10 s, but the config sets no testTimeout, so Vitest's 5 s default applies. A stalled write would then fail with a generic timeout instead of the "capture must start one grace timer once written" assertion, and the loop would keep running with fake timers until the 10 s mark. You could set the deadline below 5 s (for example 4_000) or give the test an explicit timeout above 10 s. Take it or leave it. |
|
Summary
screenshotAndroid drops a display rotation probe still running after the captureflaked on Coverage CI (run, on #3241, which doesn't touch this code). It failed with "the capture must start one grace timer once written".The test waits for the real PNG write, which runs on the libuv thread pool, before asserting that the 250 ms grace timer is installed. It allowed a fixed 1,000
setImmediateturns, but a loaded thread pool can need more than that. The wait is now bounded by wall time (10 s,performance.now(), which the fake timers don't touch, since onlysetTimeout/clearTimeoutare faked). The assertions are unchanged.Validation
UV_THREADPOOL_SIZE=1plus onepbkdf2call) during the capture. The old test fails with the CI assertion; the new one passes.pnpm check:affected --runpassed.🤖 Generated with Claude Code