Skip to content

Commit 9a2a48c

Browse files
committed
test(web): the late-boundary truncation spec waits for done, not 80 ms
hydrate() plus its flush took 12-218 ms locally on a busy machine, and done lands two macrotasks after it. When the first of those ran past the spec's fixed sleep(80), the timer fired first and done was still undefined (2 of 3 isolated runs failed on next while another job loaded the machine). Stalling the event loop for 100 ms right after scheduling the wait reproduces it every time. The spec now polls done every 10 ms for up to a second; a boundary that waits for a swap instead of the rejected path still never reaches done and fails.
1 parent 1dd4466 commit 9a2a48c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎packages/web/test/hydration/truncated-stream-late-boundary.spec.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ test("a boundary registering after the cut releases through the rejected path",
5050

5151
const dispose = hydrate(() => <scenario.App />, container);
5252
flush();
53-
await sleep(80);
54-
flush();
53+
// Done lands two macrotasks after hydrate(), and the first of them can
54+
// outlast a fixed wait on a busy machine: wait for done itself, bounded.
55+
for (let i = 0; i < 100 && !hy.done; i++) {
56+
await sleep(10);
57+
flush();
58+
}
5559
expect(hy.done).toBe(true);
5660

5761
warn.mockRestore();

0 commit comments

Comments
 (0)