Node version and platform
$ node -v
v16.0.0
$ uname -a
Darwin Troelss-Mac-mini.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:41 PDT 2021; root:xnu-7195.101.2~1/RELEASE_ARM64_T8101 arm64
What steps will reproduce the bug?
let os = require('os')
let net = require('net')
let crypto = require('crypto')
let socketPath = `${os.tmpdir()}/${crypto.randomBytes(12).toString('hex')}.sock`
let server = net.createServer(socket => {
let buffer = Buffer.alloc(0)
socket.on('data', chunk => {
if(chunk.toString('utf8') === 'destroy') {
console.log('server destroy')
socket.destroy()
}
})
})
server.on('listening', () => {
// client closes
const socket1 = net.connect({ path: socketPath })
socket1.on('error', (e) => {
console.log('socket1:' + e.toString())
})
socket1.end()
socket1.write('hello')
// server closes
const socket2 = net.connect({ path: socketPath })
socket2.on('error', (e) => {
console.log('socket2:' + e.toString())
})
socket2.write('destroy')
setTimeout(() => {
socket2.write()
}, 1000)
})
server.listen(socketPath)
How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior?
Node 12.x:
$ /opt/homebrew/Cellar/node@12/12.22.1_1/bin/node socket-errors.js
socket1:Error [ERR_STREAM_WRITE_AFTER_END]: write after end
server destroy
socket2:Error: This socket has been ended by the other party
Node 14.x:
$ /opt/homebrew/Cellar/node@14/14.17.0/bin/node socket-errors.js
socket1:Error [ERR_STREAM_WRITE_AFTER_END]: write after end
server destroy
socket2:Error: This socket has been ended by the other party
What do you see instead?
Node 16.x:
$ /opt/homebrew/Cellar/node/16.0.0_1/bin/node socket-errors.js
socket1:Error [ERR_STREAM_WRITE_AFTER_END]: write after end
server destroy
Additional information
Node version and platform
$ node -v v16.0.0 $ uname -a Darwin Troelss-Mac-mini.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:41 PDT 2021; root:xnu-7195.101.2~1/RELEASE_ARM64_T8101 arm64What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior?
Node 12.x:
Node 14.x:
What do you see instead?
Node 16.x:
Additional information