diff options
author | Claudio Rodriguez <cjrodr@yahoo.com> | 2016-09-06 17:34:18 +0100 |
---|---|---|
committer | Ilkka Myller <ilkka.myller@nodefield.com> | 2016-09-24 01:24:04 +0300 |
commit | 1b97774c44293234a950c89d6fc3ff7a88f4f1b7 (patch) | |
tree | 7e927bc6e405c4962c220fd9d793f6d7e2bca2f5 /test/parallel/test-fs-watch-stop-sync.js | |
parent | 0f2f8efdde82f08e043a4f1a301ae099aa7ee5f8 (diff) | |
download | node-new-1b97774c44293234a950c89d6fc3ff7a88f4f1b7.tar.gz |
fs: do not emit 'stop' watch event synchronously
Emits 'stop' event for fs.watchFile on process.nextTick
to fix 'maximum call stack size exceeded' error when
`stop` is called synchronously after listener is attached.
PR-URL: https://github.com/nodejs/node/pull/8524
Fixes: https://github.com/nodejs/node/issues/8421
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
Diffstat (limited to 'test/parallel/test-fs-watch-stop-sync.js')
-rw-r--r-- | test/parallel/test-fs-watch-stop-sync.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/parallel/test-fs-watch-stop-sync.js b/test/parallel/test-fs-watch-stop-sync.js new file mode 100644 index 0000000000..1444ff6bfd --- /dev/null +++ b/test/parallel/test-fs-watch-stop-sync.js @@ -0,0 +1,9 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const fs = require('fs'); + +const watch = fs.watchFile(__filename, () => {}); +watch.once('stop', assert.fail); // Should not trigger. +watch.stop(); +watch.removeListener('stop', assert.fail); |