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

Received an unknown event from fsevents then watcher fired unlink event for the directory recursively #1286

Closed
Singloo opened this issue Aug 14, 2023 · 7 comments

Comments

@Singloo
Copy link

Singloo commented Aug 14, 2023

Describe the bug

I'm using vite in work dir WORKDIR, but everytime after running vite for a while, chokidar will fire unlink events to all files under WORKDIR recursively.

I debugged a little, I found that the root cause is an unknown event from fsevents.
Here is the data of the event

{
  path: `${WORKDIR}`,
  flags: 3,
  event: "unknown",
  type: undefined,
  changes: {
    inode: false,
    finder: false,
    access: false,
    xattrs: false,
  },
}

Then this line of code will be triggered

Versions (please complete the following information):

  • Chokidar version latest
  • Node version: tried both 16.17.0 and 18.15.0
  • OS version: MacOS 13.5

To Reproduce:

I cannot reproduce this issue on other project

Expected behavior
Provide a way to ignore some unknown events.

Additional context
I have watchman, pm2 running on my device

@segevfiner
Copy link

Hitting this as well, and it likely causes this two: storybookjs/storybook#22253 vitejs/vite#14126. Though for me it gets triggered from this line

this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
and a similar kind of unknown event.

@segevfiner
Copy link

segevfiner commented Aug 17, 2023

This event basically means that chokidar or its user isn't processing events fast enough, and as such, must rescan the directory recursively for changes by itself as the FSEvents API dropped/coalesced those events. But for some reason type seems to be unset for this event which confuses chokidar. There seems to be a fix for this in fsevents already: fsevents/fsevents@63709df, but it wasn't released. You can use patch-package/pnpm patch or so on to apply the fix locally or override to get fsevents from Git.

https://developer.apple.com/documentation/coreservices/kfseventstreameventflagmustscansubdirs https://developer.apple.com/documentation/coreservices/kfseventstreameventflaguserdropped

@Singloo
Copy link
Author

Singloo commented Aug 18, 2023

This event basically means that chokidar or its user isn't processing events fast enough, and as such, must rescan the directory recursively for changes by itself as the FSEvents API dropped/coalesced those events. But for some reason type seems to be unset for this event which confuses chokidar. There seems to be a fix for this in fsevents already: fsevents/fsevents@63709df, but it wasn't released.

https://developer.apple.com/documentation/coreservices/kfseventstreameventflagmustscansubdirs https://developer.apple.com/documentation/coreservices/kfseventstreameventflaguserdropped

It works, many thanks

@segevfiner
Copy link

@paulmillr Making a release of fsevents will solve this.

@IanVS
Copy link

IanVS commented Aug 21, 2023

Hi @paulmillr, this is effecting a fairly large number of Vite and Storybook users. Do you think it would be possible to cut a release of fsevents in the near future?

Thanks @Singloo and @segevfiner for troubleshooting and finding the cause!

@paulmillr
Copy link
Owner

@pipobscure what's needed to publish this? Seems like GitHub publish workflow is failing. Not sure where to begin.

@pipobscure
Copy link
Contributor

Released as v2.3.3

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