This helps to prevent issues where a failed test can keep a bound socket open long enough to cause other tests to fail with EADDRINUSE because the same port number is used. PR-URL: https://github.com/nodejs/node/pull/7045 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
28 lines
681 B
JavaScript
28 lines
681 B
JavaScript
'use strict';
|
|
require('../common');
|
|
var assert = require('assert');
|
|
var net = require('net');
|
|
var accessedProperties = false;
|
|
|
|
var server = net.createServer(function(socket) {
|
|
socket.end();
|
|
});
|
|
|
|
server.listen(0, function() {
|
|
var client = net.createConnection(this.address().port);
|
|
server.close();
|
|
// server connection event has not yet fired
|
|
// client is still attempting to connect
|
|
assert.doesNotThrow(function() {
|
|
client.remoteAddress;
|
|
client.remoteFamily;
|
|
client.remotePort;
|
|
});
|
|
accessedProperties = true;
|
|
// exit now, do not wait for the client error event
|
|
process.exit(0);
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert(accessedProperties);
|
|
});
|