oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.47k stars 2.78k forks source link

fs.watch cannot detect changes in files that are created after bun starts #15085

Open aster-void opened 2 weeks ago

aster-void commented 2 weeks ago

What version of Bun is running?

1.1.34 . bun installed bun today, and copied the executable from node_modules.

What platform is your computer?

Linux 5.15.153.1-microsoft-standard-WSL2 x86_64 unknown (NixOS)

What steps can reproduce the bug?

  1. create watch.ts
import fs from "node:fs";

fs.watch(".", undefined, (ev, file) => {
  console.log(`${ev}: ${file}`)
});
  1. touch test
  2. echo 'hi' > test

What is the expected behavior?

should log "rename test" at step 2and "change test" at step 3

What do you see instead?

only logs "rename test" on step2

Additional information

No response

Jarred-Sumner commented 2 weeks ago

WSL2

Are you by chance trying to use fs.watch on the Windows partition?

aster-void commented 2 weeks ago

I'm not sure what that means, but I'm running it inside my /home/(username) dir.

mauritsd commented 1 week ago

We have this on 'pure' linux as well (Ubuntu 20.04). Have experimented a little bit, closing and recreating the watch does not seem to fix it, but restarting the process doing the watching will.

EmielM commented 1 week ago

This is currently a big impediment for us to upgrade our developer scripts from node, as after a while recursively watching our source folder(s) to trigger rebuilds (silently) stops working and is a productivity kill for devs. Ubuntu 20, any bun version 1.1.22 - 1.1.35.

Seems to occur for both node-watch and fs.watch (with recursive: true).