Skip to content

Commit 027701b

Browse files
thymikeeclaude
andcommitted
test(android): bound the screenshot write wait by wall time, not event-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) <[email protected]>
1 parent 0fef406 commit 027701b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎packages/platform-android/src/__tests__/screenshot.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ test('screenshotAndroid drops a display rotation probe still running after the c
9999
facts = result;
100100
});
101101
// The image is written through real file I/O; the only timer this path installs is the
102-
// grace that starts once the write is done. Yield to I/O until it exists.
103-
for (let turn = 0; turn < 1_000 && vi.getTimerCount() === 0; turn++) {
102+
// grace that starts once the write is done. Yield to I/O until it exists, bounded by wall
103+
// time because a loaded thread pool can take any number of event-loop turns to finish it.
104+
const writeDeadline = performance.now() + 10_000;
105+
while (vi.getTimerCount() === 0 && performance.now() < writeDeadline) {
104106
await new Promise((resolve) => setImmediate(resolve));
105107
}
106108
assert.equal(vi.getTimerCount(), 1, 'the capture must start one grace timer once written');

0 commit comments

Comments
 (0)