fs.watchFile: no change event when the stat error code changes while the file is missing
What happens
fs.watchFile emits one change event when a watched path starts to fail stat(). Node emits one more change event each time the error code of the failed stat() changes, for example ENOENT to ENOTDIR. The arguments are the same each time: a zeroed current and the last real stat as previous.
The mechanism is in libuv's poll_cb, which calls back when busy_polling != req->result:
https://github.com/libuv/libuv/blob/5152db2cbfeb5582e9c27c5ea1dba2cd9e10759b/src/fs-poll.c#L200-L208
Bun treats every failed stat() the same (src/runtime/node/node_fs_stat_watcher.rs, restat()).
Repro
Watch d/f.txt. Remove d (stat fails with ENOENT). Create a regular file named d (ENOTDIR). Remove it (ENOENT). Restore d/f.txt.
node v26.3.0: 4 callbacks (gone, gone, gone, back)
bun 1.4.3: 2 callbacks (gone, back)
Found while working on #43050, which does not change this.
Source: oven-sh/bun