mirror of https://github.com/lukechilds/node.git
Browse Source
This commit adds test coverage for the scenario where a socket's handle has been closed prior to writing. PR-URL: https://github.com/nodejs/node/pull/13171 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>v6
1 changed files with 39 additions and 0 deletions
@ -0,0 +1,39 @@ |
|||
'use strict'; |
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const net = require('net'); |
|||
|
|||
{ |
|||
const server = net.createServer(); |
|||
|
|||
server.listen(common.mustCall(() => { |
|||
const port = server.address().port; |
|||
const client = net.connect({port}, common.mustCall(() => { |
|||
client.on('error', common.mustCall((err) => { |
|||
server.close(); |
|||
assert.strictEqual(err.constructor, Error); |
|||
assert.strictEqual(err.message, 'write EBADF'); |
|||
})); |
|||
client._handle.close(); |
|||
client.write('foo'); |
|||
})); |
|||
})); |
|||
} |
|||
|
|||
{ |
|||
const server = net.createServer(); |
|||
|
|||
server.listen(common.mustCall(() => { |
|||
const port = server.address().port; |
|||
const client = net.connect({port}, common.mustCall(() => { |
|||
client.on('error', common.mustCall((err) => { |
|||
server.close(); |
|||
assert.strictEqual(err.constructor, Error); |
|||
assert.strictEqual(err.message, 'This socket is closed'); |
|||
})); |
|||
client._handle.close(); |
|||
client._handle = null; |
|||
client.write('foo'); |
|||
})); |
|||
})); |
|||
} |
Loading…
Reference in new issue