Skip to content

Commit ad2b272

Browse files
Imran Iqbalrvagg
Imran Iqbal
authored andcommitted
test: fix test-net-keepalive for AIX
Fixed an intermittent issue on AIX where the 100ms timeout was reached before the 'connection' event was fired. This resulted in a failure as serverConnection would be undefined and the assert.equal would throw an error. Changed the flow of the test so that the timeout is only set after a connection has been made. Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> PR-URL: #3458
1 parent 605c5a7 commit ad2b272

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test/parallel/test-net-keepalive.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ var assert = require('assert');
44
var net = require('net');
55

66
var serverConnection;
7+
var clientConnection;
78
var echoServer = net.createServer(function(connection) {
89
serverConnection = connection;
10+
setTimeout(function() {
11+
// make sure both connections are still open
12+
assert.equal(serverConnection.readyState, 'open');
13+
assert.equal(clientConnection.readyState, 'open');
14+
serverConnection.end();
15+
clientConnection.end();
16+
echoServer.close();
17+
}, common.platformTimeout(100));
918
connection.setTimeout(0);
1019
assert.notEqual(connection.setKeepAlive, undefined);
1120
// send a keepalive packet after 50 ms
@@ -17,15 +26,6 @@ var echoServer = net.createServer(function(connection) {
1726
echoServer.listen(common.PORT);
1827

1928
echoServer.on('listening', function() {
20-
var clientConnection = net.createConnection(common.PORT);
29+
clientConnection = net.createConnection(common.PORT);
2130
clientConnection.setTimeout(0);
22-
23-
setTimeout(function() {
24-
// make sure both connections are still open
25-
assert.equal(serverConnection.readyState, 'open');
26-
assert.equal(clientConnection.readyState, 'open');
27-
serverConnection.end();
28-
clientConnection.end();
29-
echoServer.close();
30-
}, common.platformTimeout(100));
3131
});

0 commit comments

Comments
 (0)