Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions packages/metro-file-map/src/watchers/FallbackWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ export default class FallbackWatcher extends AbstractWatcher {
this.#checkedEmitError,
this.ignored,
);

if (platform === 'win32') {
// Inherited from sane: win32 needs a settling period after the watches
// are registered before events can be relied on.
await new Promise(resolve => setTimeout(resolve, 1000));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,35 @@ describe('FallbackWatcher', () => {
await expect(watcher?.startWatching()).resolves.toBeUndefined();
});

// Every watch is live once `startWatching` resolves, Windows included.
// Skipped on macOS, where `fs.watch` starts FSEvents streams asynchronously
// (FallbackWatcher isn't used there).
(process.platform === 'darwin' ? test.skip : test)(
'reports changes made as soon as it has started',
async () => {
const dirs = Array.from({length: 20}, (_, i) => join(watchRoot, `d${i}`));
for (const dir of dirs) {
await mkdir(dir);
}
const touched = new Set<string>();
watcher?.onFileEvent(event => {
if (event.event === 'touch' && event.metadata?.type === 'f') {
touched.add(event.relativePath);
}
});

await watcher?.startWatching();
for (const dir of dirs) {
await writeFile(join(dir, 'file.js'), '');
}

await waitFor(() => touched.size === dirs.length);
expect(touched).toEqual(
new Set(dirs.map((_, i) => join(`d${i}`, 'file.js'))),
);
},
);

// A watch we cannot establish - one directory over the inotify limit, say -
// must not cost us the files under it, which would silently truncate the
// file map.
Expand Down
Loading