Chokidar: Chokidar can trigger itself simply by starting up

Created on 22 Jul 2018  路  3Comments  路  Source: paulmillr/chokidar

Consider the following instruction:

chokidar.watch('src/*.js').on('add', (event, path) => {
  console.log(event, path); 
});

This will in fact trigger the "on add" call as many times as there are files to monitor, as chokidar treats its own file discover as if it's a filesystem "file came into existence" event, which seems quite wrong.

Rather, the add, change, unlink, addDir, and unlinkDir events should not fire until after ready, unless the user specifies they want this counter-intuitive behaviour through some options override (like having to explicitly set { waitForReady: false })

Most helpful comment

ignoreInitial: true

All 3 comments

ignoreInitial: true

That should probably be made a default, rather than defaulting to false.

But until then, this option should be prominently mentioned early in the README.md as a "be aware of the following behaviour, because it can lead to a crazy bad time if you don't either set this to true, or wait for ready".

I think it should default to true

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jbreckmckye picture jbreckmckye  路  7Comments

yebrahim picture yebrahim  路  4Comments

Tilogorn picture Tilogorn  路  6Comments

paulmillr picture paulmillr  路  9Comments

ORESoftware picture ORESoftware  路  8Comments