- Version: v10.16.0
- Platform: Darwin Dans-MacBook-Pro-4.local 16.7.0 Darwin Kernel Version 16.7.0: Wed Feb 27 00:29:57 PST 2019; root:xnu-3789.73.43~1/RELEASE_X86_64 x86_64
- Subsystem: fs
Code to reproduce:
const assert = require('assert');
const { createWriteStream, watch, readFileSync } = require('fs');
const doc = '{ "a": 1 }';
const filename = '/tmp/reproducer.txt';
const outStream = createWriteStream(filename);
setTimeout(() => outStream.write(doc), 2000);
const watcher = watch(filename, function(eventType) {
assert.equal(eventType, 'change');
var fileContents = readFileSync(filename, 'utf8');
try {
var parsedFileContents = JSON.parse(fileContents);
assert.equal(parsedFileContents.a, 1);
console.log('success');
} catch (e) {
console.log(e);
console.log(`JSON contents: \`${fileContents}\``);
} finally {
watcher.close();
console.log('done');
}
});
Output in node v10.15.3:
Output in node v10.16.0:
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at FSWatcher.<anonymous> (/Users/daprahamian/src/node-mongodb-native/repro.js:17:35)
at FSWatcher.emit (events.js:198:13)
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:131:12)
JSON contents: ``
done
Is this an intentional change, or a regression?
Code to reproduce:
Output in node v10.15.3:
Output in node v10.16.0:
Is this an intentional change, or a regression?