From c6d244ef83e2d5968726711f77f53d2402d1c3ab Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 11 Mar 2026 12:08:57 -0700 Subject: [PATCH 1/2] Fix flaky streamer test ENOENT when chunks directory does not exist yet --- packages/world-local/src/streamer.test.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/world-local/src/streamer.test.ts b/packages/world-local/src/streamer.test.ts index 0c32ad9661..3c5d099e0b 100644 --- a/packages/world-local/src/streamer.test.ts +++ b/packages/world-local/src/streamer.test.ts @@ -95,12 +95,19 @@ describe('streamer', () => { if (!ctx.task.result?.errors?.length) { await fs.rm(testDir, { recursive: true, force: true }); } else { - const files = await fs.readdir(`${testDir}/streams/chunks`); + const chunksPath = `${testDir}/streams/chunks`; + let files: string[]; + try { + files = await fs.readdir(chunksPath); + } catch { + // chunks directory may not exist if the test failed before any writes + files = []; + } const chunks = [] as unknown[]; let lastTime = 0; for (const file of files) { const chunk = deserializeChunk( - await fs.readFile(`${testDir}/streams/chunks/${file}`) + await fs.readFile(`${chunksPath}/${file}`) ); // Extract ULID from filename: "streamName-chnk_ULID.bin" const chunkIdPart = String(file.split('-').at(-1)).split('.')[0]; // "chnk_ULID" From a24fe94ab81f26141a8a7b51f929411c373bb04c Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 11 Mar 2026 12:13:15 -0700 Subject: [PATCH 2/2] Reduce race condition test iterations to avoid timeout on slow CI --- packages/world-local/src/streamer.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/world-local/src/streamer.test.ts b/packages/world-local/src/streamer.test.ts index 3c5d099e0b..e381716249 100644 --- a/packages/world-local/src/streamer.test.ts +++ b/packages/world-local/src/streamer.test.ts @@ -507,8 +507,11 @@ describe('streamer', () => { }); it('should not lose or duplicate chunks written during stream initialization (race condition test)', async () => { - // Run multiple iterations to increase probability of catching race conditions - for (let iteration = 0; iteration < 10; iteration++) { + // Run multiple iterations to increase probability of catching race conditions. + // Keep the count low — each iteration creates a fresh streamer with its own + // temp directory, and per-chunk I/O on Windows CI can be ~100-200ms which + // easily blows the timeout at higher counts. + for (let iteration = 0; iteration < 3; iteration++) { const { streamer } = await setupStreamer(); const streamName = `race-${iteration}`;