Skip to content

Commit cbe955c

Browse files
committed
test: add net regression test
Ensure that the socket is not destroyed when the 'end' event is emitted. Refs: #32780 (comment) PR-URL: #32794 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent cf4c332 commit cbe955c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const net = require('net');
5+
const assert = require('assert');
6+
7+
const server = net.createServer();
8+
9+
server.on('connection', common.mustCall());
10+
11+
// Ensure that the socket is not destroyed when the 'end' event is emitted.
12+
13+
server.listen(common.mustCall(function() {
14+
const socket = net.createConnection({
15+
port: server.address().port
16+
});
17+
18+
socket.on('connect', common.mustCall(function() {
19+
socket.on('end', common.mustCall(function() {
20+
assert.strictEqual(socket.destroyed, false);
21+
server.close();
22+
}));
23+
24+
socket.end();
25+
}));
26+
}));

0 commit comments

Comments
 (0)