node-watch
node-watch copied to clipboard
Use async fs functions
This is my attempt at getting rid of synchronous fs calls, which is supposed to fix https://github.com/yuanchuan/node-watch/issues/107. I too noticed that the event loop was blocked in some scenarios, for example when a high number of files was being created in watched folder in a short period of time. After these changes it performs much better and doesn't block.
I decided to use fs-extra for the promise-based functions but that might have been unnecessary because that library supports only node >= 12, so node-watch doesn't really gain anything by using it.
But are you okay with dropping support for some older versions of node at all?
I could do the following things if node >= 12 was too high:
- wrap the callback-based functions myself but keep async/await: node >= 8
- use fs.promises: node >= 10
I think that would also mean recursive: true
would always be natively supported.
Hi @ianshade, thank you so much for the effort!
I would like to use latest JS features but the current plan is to keep this project change as less as possible. I'm not sure if the change will bring other issues, which is acceptable. I just don't have much time to continue to test and fix them.
I'll hold this pr for some time!
I need to close this PR. Thanks again!