Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions packages/world-local/src/streamer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Comment on lines +98 to +102
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The broad catch { files = [] } will also hide unexpected errors (e.g., EACCES/corrupted temp dir) and can make failures harder to diagnose. Consider catching the error, only treating ENOENT as an empty directory, and rethrowing anything else. Also, since this is Windows-flake related and the rest of the file uses path.join, building chunksPath via path.join(testDir, 'streams', 'chunks') would be more consistent and robust.

Copilot uses AI. Check for mistakes.
// 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"
Expand Down Expand Up @@ -500,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}`;

Expand Down
Loading