Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New files are not detected #1361

Open
S-Stanley opened this issue Sep 19, 2024 · 6 comments
Open

New files are not detected #1361

S-Stanley opened this issue Sep 19, 2024 · 6 comments

Comments

@S-Stanley
Copy link

Describe the bug

We have a desktop app using [email protected]. Chokidar is used to detect new file created in a specific directory. After upgrading from 3.6.0 to 4.0.0, new files are not detected 2/3 of the time.

  • Updating the file when it's already created, for example updating the name of the file, make it accessible for chokidar
  • Downgrading to 3.6.0 solved the issue for us

Versions (please complete the following information):

  • Chokidar version 4.0.0
  • Node version 16
  • OS version: Window 11

To Reproduce:

  1. Upgrade to [email protected]
  2. Add a new file in the directory watched
watcher = chokidar.watch("~/example-directory", {
  ignored: /(^|[/\\])\../,
  persistent: true,
  ignoreInitial: true,
});
watcher.on("add", path => {
 // this function is not triggered 2/3 times when a new file is created in the directory
})

Expected behavior

Chokidar detect the new file added in the directory watched

Additional context

Downgrading to 3.6.0 solved the issue for us

@paulmillr
Copy link
Owner

Try removing “ignored” and seeing what happens.

@S-Stanley
Copy link
Author

Thanks for your quick answer, I feel like it's better, working 1/2 times but not everytime

@43081j
Copy link
Collaborator

43081j commented Sep 20, 2024

I'll have a look when I'm next on a laptop too

The underlying logic hasn't actually changed much since 3.x other than removing glob support. So I am surprised you're seeing a difference in behaviour

@S-Stanley
Copy link
Author

Thanks, let me know if you need more informations

I will take a look on the weekend as well

@seans84
Copy link

seans84 commented Sep 24, 2024

I'm experiencing a similar error in a Rails project as well. New JavaScript is not detected when added to any existing or new files. Old, cached assets, are being served instead.

Downgrading back to 3.6.0 solves this issue.

I did notice something strange. In my lock file I now have two references to chokidar
Screenshot 2024-09-24 at 10 50 59 AM

I'm not sure if this is the cause of the issue or not.

@paulmillr paulmillr changed the title Error while migrating from v3.6.0 to v4.0.0 - new files are not detected v4: new files are not detected Sep 27, 2024
@DominoPivot
Copy link

DominoPivot commented Oct 2, 2024

This bug also affects change events when performing atomic writes, which are occasionally replaced with unlink events. 😬

This took me a while to debug, because it's my first time using chokidar and this was the output of my build script (all files were deleted, then recreated):

Starting watcher.
Removing stale files.
Running esbuild.
m out\stylesheets\style.css
m out\oranges\popover.js    
m out\oranges\popover.js.map
- out\nosdk.js
- out\nosdk.js.map
- out\sdk.js
- out\sdk.js.map
m out\oranges\popover.js.map
- out\stylesheets\style.css.map

The rebuild happened fast enough for changes to be considered atomic, but most of the writes weren't detected by chokidar. Combine that with the fact (arguably a bug) that atomic change events are fired without delay, and the fact esbuild sometimes writes to the same file twice, and you get an output that gives the impression you forgot to wait for all deletions to be done before running the build, even though you did 🙃

@paulmillr paulmillr changed the title v4: new files are not detected New files are not detected Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants