Skip to content

Commit 0a1c18e

Browse files
committed
test: add net regression test
Ensure that the socket is not destroyed when the 'end' event is emitted. Refs: #32780 (comment)
1 parent aeb7084 commit 0a1c18e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 socket is not destroyed before
12+
// emitting 'end'.
13+
14+
server.listen(common.mustCall(function() {
15+
const socket = net.createConnection({
16+
port: server.address().port
17+
});
18+
19+
socket.on('connect', common.mustCall(function() {
20+
socket.on('end', common.mustCall(function() {
21+
assert.strictEqual(socket.destroyed, false);
22+
server.close();
23+
}));
24+
25+
socket.end();
26+
}));
27+
}));

0 commit comments

Comments
 (0)