Skip to content

Commit 610ac7d

Browse files
DavidCai1111jasnell
authored andcommitted
test: increase coverage of internal/socket_list
PR-URL: #12066 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 085c1f8 commit 610ac7d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

test/parallel/test-internal-socket-list-receive.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const key = 'test-key';
1717

1818
const list = new SocketListReceive(child, key);
1919
list.child.emit('internalMessage', { key, cmd: 'NODE_SOCKET_NOTIFY_CLOSE' });
20+
list.child.emit('internalMessage', { key, cmd: 'NODE_SOCKET_GET_COUNT' });
2021
}
2122

2223
// Verify that a "NODE_SOCKET_ALL_CLOSED" message will be sent.

test/parallel/test-internal-socket-list-send.js

+22
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,25 @@ const key = 'test-key';
112112
assert.strictEqual(child.listenerCount('disconnect'), 0);
113113
}));
114114
}
115+
116+
// Verify that an error will be received in callback when child is
117+
// disconnected after sending a message and before getting the reply.
118+
{
119+
const count = 1;
120+
const child = Object.assign(new EventEmitter(), {
121+
connected: true,
122+
send: function(msg) {
123+
process.nextTick(() => {
124+
this.emit('disconnect');
125+
this.emit('internalMessage', { key, count, cmd: 'NODE_SOCKET_COUNT' });
126+
});
127+
}
128+
});
129+
130+
const list = new SocketListSend(child, key);
131+
132+
list.getConnections(common.mustCall((err, msg) => {
133+
assert.strictEqual(err.message, 'child closed before reply');
134+
assert.strictEqual(child.listenerCount('internalMessage'), 0);
135+
}));
136+
}

0 commit comments

Comments
 (0)