Skip to content

Commit

Permalink
test: add net regression test
Browse files Browse the repository at this point in the history
Ensure that the socket is not destroyed when the 'end'
event is emitted.

Refs: nodejs#32780 (comment)

PR-URL: nodejs#32794
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
ronag committed Apr 14, 2020
1 parent cf4c332 commit cbe955c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/parallel/test-net-end-destroyed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const common = require('../common');
const net = require('net');
const assert = require('assert');

const server = net.createServer();

server.on('connection', common.mustCall());

// Ensure that the socket is not destroyed when the 'end' event is emitted.

server.listen(common.mustCall(function() {
const socket = net.createConnection({
port: server.address().port
});

socket.on('connect', common.mustCall(function() {
socket.on('end', common.mustCall(function() {
assert.strictEqual(socket.destroyed, false);
server.close();
}));

socket.end();
}));
}));

0 comments on commit cbe955c

Please sign in to comment.