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

Error when deleting large number of files #171

Closed
tsmaeder opened this issue Nov 21, 2022 · 1 comment · Fixed by #172
Closed

Error when deleting large number of files #171

tsmaeder opened this issue Nov 21, 2022 · 1 comment · Fixed by #172

Comments

@tsmaeder
Copy link
Contributor

This is a linux-only problem. Here's how to reproduce:

  1. Run the following nodejs program on Linux (Ubuntu latest LTS is my platform)
const nsfw = require('nsfw');

console.log(`watching ${process.argv[2]`}`);

const watch= nsfw(process.argv[2], events => {
   console.log('got events');
   event.forEach(element => {
      console.log(JSON.stringify({...element}));
}, {
   errorCallback: err => {
      console.error(err);
   }
}).then(instance => {
   instance.start();
   console.log('watch started');
});

the program expects as a paremeter with a large (> 1000) number of directories. A node_modules folder of a complex project makes for good test data.

  1. In the Ubuntu "Files" file explorer, select all subdirectories of the dir you passed as a paramenter in 1. and hit the delete button
  2. Observe: after a while, you get an error message in the console:
Error: Service shutdown: root path changed (rename or deleted) 
@tsmaeder
Copy link
Contributor Author

The number of directories you need to delete to in order to provoke the bug is timing dependent: the relevant difference is that we get more than one even in the event buffer in InotifyEventLoop#work(). You can provoke this by putting a breakpoint in the loop reading the evnents in InotifyEventLoop#work(), for example on line 131.
I believe the problem stems from the fact that the renameEnd block uses renameEvent.isDirectory to determine that this is an event that describes the delete of a watched directory. However, what we should be looking at is the isDirectoryRemoval flag instead, as it's done in the remove block.

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

Successfully merging a pull request may close this issue.

1 participant