Closed
Description
- Version: v10.3.0
- Platform: Linux dev 4.15.0-22-generic Simple project messaging. #24-Ubuntu SMP Wed May 16 12:15:17 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem:
The following code illustrates the observed issue:
// index.js
const fs = require('fs')
const {resolve} = require('path')
function copy (source, target, cb) {
const read = fs.createReadStream(source)
const write = fs.createWriteStream(target, {flags: 'w'})
function copyit () {
if (copyit.once) return
copyit.once = true
console.log('copyit')
write.on('error', function (err) {
console.log('onerror')
cb(err)
})
write.on('close', function () {
console.log('onclose')
cb(null)
})
read.pipe(write)
}
read.on('readable', copyit)
read.on('end', copyit)
}
const source = resolve(__dirname, 'index.js')
const target = resolve(__dirname, 'copy.js')
copy(source, target, (err) => {
console.log('end', err)
})
On node>=10.0 only the readable
event fires
copyit
On node@9.11.1 the output is
copyit
onclose
end null