Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9ac8d41

Browse filesBrowse files
davedoesdevtargos
authored andcommitted
net: check for close on stream, not parent
'close' event isn't emitted on a TLS connection if it's been written to (but 'end' and 'finish' events are). PR-URL: #25026 Fixes: #24984 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 91d1aea commit 9ac8d41
Copy full SHA for 9ac8d41

File tree

Expand file treeCollapse file tree

2 files changed

+43
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+43
-2
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ Socket.prototype._final = function(cb) {
368368
};
369369

370370

371-
function afterShutdown(status, handle) {
372-
var self = handle[owner_symbol];
371+
function afterShutdown(status) {
372+
var self = this.handle[owner_symbol];
373373

374374
debug('afterShutdown destroyed=%j', self.destroyed,
375375
self._readableState);
Collapse file
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
// Issue #24984
8+
// 'close' event isn't emitted on a TLS connection if it's been written to
9+
// (but 'end' and 'finish' events are). Without a fix, this test won't exit.
10+
11+
const tls = require('tls');
12+
const fixtures = require('../common/fixtures');
13+
let cconn = null;
14+
let sconn = null;
15+
16+
function test() {
17+
if (cconn && sconn) {
18+
cconn.resume();
19+
sconn.resume();
20+
sconn.end(Buffer.alloc(1024 * 1024));
21+
cconn.end();
22+
}
23+
}
24+
25+
const server = tls.createServer({
26+
key: fixtures.readKey('agent1-key.pem'),
27+
cert: fixtures.readKey('agent1-cert.pem')
28+
}, function(c) {
29+
c.on('close', function() {
30+
server.close();
31+
});
32+
sconn = c;
33+
test();
34+
}).listen(0, common.mustCall(function() {
35+
tls.connect(this.address().port, {
36+
rejectUnauthorized: false
37+
}, common.mustCall(function() {
38+
cconn = this;
39+
test();
40+
}));
41+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.