From 7658ffaaa38d2638ab3cc4c54d11349fd93c4682 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Sat, 23 Mar 2019 12:48:46 -0300 Subject: [PATCH] Use self.* in callback to update and close watcher (#97) onchange callback sets this to the reported FSEvent rather than the outer FSWatcher --- lib/fs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index ea7d34295bfd9f..473a7196697e06 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1380,10 +1380,10 @@ function FSWatcher() { // after the handle is closed, and to fire both UV_RENAME and UV_CHANGE // if they are set by libuv at the same time. if (status < 0) { - if (this._handle !== null) { + if (self._handle !== null) { // We don't use this.close() here to avoid firing the close event. - this._handle.close(); - this._handle = null; // make the handle garbage collectable + self._handle.close(); + self._handle = null; // make the handle garbage collectable } const error = errors.uvException({ errno: status,