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

Do I need to worry about disposing chokidar watchers? #945

Closed
blake-mealey opened this issue Nov 3, 2019 · 2 comments
Closed

Do I need to worry about disposing chokidar watchers? #945

blake-mealey opened this issue Nov 3, 2019 · 2 comments

Comments

@blake-mealey
Copy link

This isn't a bug report, so I'm not sure if this is the correct place to put this. Please redirect me if necessary.

I'm working on adding file-watching support to a Rollup plugin (rollup-plugin-copy) using Chokidar (see this discussion for why we want to use Chokidar: vladshcherbin/rollup-plugin-copy#27 (comment)), and I'm wondering if I need to make sure I call FSWatcher.close() before the process exits. If so, I'm not sure what the recommended way to do so is, because using process.on('exit', ...) requires the callback to be synchronous (see https://nodejs.org/api/process.html#process_event_exit), but FSWatcher.close() is async.

Since I'm here, I'm also curious regarding the best practices for creating more than one FSWatcher instance VS creating a single master FSWatcher with all of the paths you care about. Is there a significant performance cost for creating multiple watchers?

@paulmillr
Copy link
Owner

You don’t need to call close() before process exit.

Creating more than one instance is possible, but may create some bugs, since we don’t test this case.

@blake-mealey
Copy link
Author

Great, thanks for the help!

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

2 participants