Platform-specific kernel bug affecting fs.watch behavior.
The issue involves fs.watch() returning null for the filename argument on SunOS/SmartOS, similar to a known FreeBSD kernel bug. The problem is reproducible and test-focused, but requires deep understanding of platform-specific kernel behavior and fs module internals. The main blocker is the potential kernel-level nature of the bug.
main (commit 159ae48f8cd3)
SunOS smartos 5.11 joyent_20260122T000642Z i86pc i386 i86pc
fs
const fs = require('fs');
const watcher = fs.watch('.', {
recursive: false // The test passes if this option is set to `true`.
});
watcher.on('change', function (event, filename) {
console.log(event, filename);
if (filename === 'file.txt') {
watcher.close();
}
});
setTimeout(function () {
fs.writeFileSync('file.txt', 'data');
}, 100);
Always.
change file.txt is written to the standard output and the process exits. This is what happens when the recursive option is set to true.
change null is written to the standard output and the process does not exit.
No response
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!