12.0.0Darwin Benjamins-MacBook-Pro.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64Given the following code:
var fs = require("fs");
fs.watch('./test.txt', (event, filename) => {
console.log(event, filename);
})
Running below in a directory where test.txt exists and gets deleted yields different results for event in 12.x vs 10.x:
12.x: change10.x: renameThis basically renders node.js 12 incapable of detecting a file delete vs change when watching it.
there was no change in the fs_event binding logic, so perhaps this was an upstream change in libuv? @nodejs/libuv
There's been precisely one change to fsevents.c between v10.15.3 and v12.0.0: libuv/libuv@2d2af382ce84b91d6ee7a185af32fca7f0acd84b
@bnoordhuis for those not familiar with the libuv codebase, is that commit responsible for this behaviour change?
@devsnek I don't know, I haven't had a chance to test. But if it is a libuv issue, it must be that commit.
If someone can try reverting that patch in master or v12.x with git apply -R --directory=deps/uv and checking if that fixes the issue, that would be great.
libuv/libuv@2d2af38 is indeed responsible for the change in behavior. I'm working on a fix.
I've bundled the reported issues in #29460. That's the issue to track now.
Most helpful comment
There's been precisely one change to fsevents.c between v10.15.3 and v12.0.0: libuv/libuv@2d2af382ce84b91d6ee7a185af32fca7f0acd84b