From fcaf11a29c421b0e76c9f24f5b155a53eff14e7f Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 28 Sep 2018 10:39:20 -0700 Subject: [PATCH] fix: do not crash when using a closed fs event watcher (#70) --- doc/api/fs.md | 6 ++- lib/fs.js | 17 +++++++-- .../test-fs-watch-close-when-destroyed.js | 38 +++++++++++++++++++ test/parallel/test-fs-watch.js | 19 ++++++++-- 4 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 test/parallel/test-fs-watch-close-when-destroyed.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 26eda38f739892..30ee959928490f 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -325,7 +325,8 @@ fs.watch('./tmp', { encoding: 'buffer' }, (eventType, filename) => { added: v10.0.0 --> -Emitted when the watcher stops watching for changes. +Emitted when the watcher stops watching for changes. The closed +`fs.FSWatcher` object is no longer usable in the event handler. ### Event: 'error'