0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-fs-watch-stop-sync.js
Claudio Rodriguez 1b97774c44 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>
2016-09-24 01:24:04 +03:00

10 lines
261 B
JavaScript

'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);