-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Description
Version
20.3.0
Platform
linux
Subsystem
fs
What steps will reproduce the bug?
I put together a repro at https://github.com/cjihrig/recursive-watcher-bug that shows the following passing on Windows and macOS, but failing on Ubuntu. I'm not sure if this is specific to GitHub Actions.
'use strict';
const { mkdtempSync, watch, writeFileSync } = require('node:fs');
const { tmpdir } = require('node:os');
const { join } = require('node:path');
const tmpDir = mkdtempSync(join(tmpdir(), 'repro-test-'));
const filename = join(tmpDir, 'test.file');
const keepalive = setTimeout(() => {
throw new Error('timed out');
}, 60_000);
const watcher = watch(tmpDir, { recursive: true }, (eventType, filename) => {
clearTimeout(keepalive);
watcher.close();
console.log(eventType, filename);
});
writeFileSync(filename, 'foobar');
How often does it reproduce? Is there a required condition?
Always reproduces for me.
What is the expected behavior? Why is that the expected behavior?
I expect the test to pass.
What do you see instead?
The test times out.
Additional information
I noticed this while trying to update Platformatic to support Node 20 and created the minimal reproduction linked above.
I also noticed that Platformatic was passing recursive: true
to the promisified version of watch()
on Ubuntu on earlier versions of Node. It should have thrown ERR_FEATURE_UNAVAILABLE_ON_PLATFORM
, but did not. I did see that error with the callback based watch()
though, which makes me think there is some missing validation on older versions of Node in addition to this bug.
cc: @anonrig who implemented recursive file watching on Linux.