node icon indicating copy to clipboard operation
node copied to clipboard

fs.watch Does Not Work For WSL2 File Paths

Open NateAGeek opened this issue 3 years ago • 0 comments

  • Version: v15.12.0, and I've tested on v14.16.0 and v12.13.1 (leading me to assume it is a v15.12.0<)
  • Platform: Microsoft Windows NT 10.0.19041.0 x64
  • WSL2 Subsystem: (Ubuntu) Linux DESKTOP-**** 4.19.84-microsoft-standard #1 SMP Wed Nov 13 11:44:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: fs

What steps will reproduce the bug?

Currently I am able to reproduce the without any special edge cases or circumstance. There are requirements for getting WSL2 up, and I am using (Ubuntu) Linux DESKTOP-**** 4.19.84-microsoft-standard #1 SMP Wed Nov 13 11:44:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux.

*Create a file located someplace on the WSL2 file system. I chose to use ~/test.txt, and put some sample data in there. Then on the Windows System, have installed Node version ones listed above, and run the node REPL with the following commands.

const fs = require('fs');
fs.watch('\\\\wsl$\\Ubuntu\\home\\{WSL2_USERNAME}\\test.txt');

You will get back the following error:

Error: EISDIR: illegal operation on a directory, watch '\\wsl$\Ubuntu\home\{WSL2_USERNAME}\test.txt'
    at __node_internal_captureLargerStackTrace (node:internal/errors:415:5)
    at __node_internal_uvException (node:internal/errors:472:10)
    at FSWatcher.<computed> (node:internal/fs/watchers:244:19)
    at Object.watch (node:fs:1593:34) {
  errno: -4068,
  syscall: 'watch',
  code: 'EISDIR',
  path: '\\\\wsl$\\Ubuntu\\home\\{WSL2_USERNAME}\\test.txt',
  filename: '\\\\wsl$\\Ubuntu\\home\\{WSL2_USERNAME}\\test.txt'
}

Additional information

I thought this might have to do with the UPC paths, however, I do see fs does have UPC validation, and this is happening more on the actual syscall for watch. I might be able to pull out some more debugging info on the node_internal code, but that could lead this to be a libuv issue. I'm posting here, as it is happening while I was using node... But if someone can confirm this is actually a libuv issue, then I can move the issue to that project.

NateAGeek avatar Mar 28 '21 20:03 NateAGeek