Repository navigation
close event emitted on net socket but not tls #24984
Copy link
Copy link
Closed
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.tlsIssues and PRs related to the tls subsystem.Issues and PRs related to the tls subsystem.
Description
Activity
They both don't emit
'close'on my machine and the reason is that data is not read on the client. It works ifthis.resume()is added on the client.OS TCP buffer size perhaps then
@lpinca what about this? I don't get a
closeevent.const fs = require('fs'); const path = require('path'); const tls = require('tls'); const server = tls.createServer({ key: fs.readFileSync(path.join(__dirname, 'server.key')), cert: fs.readFileSync(path.join(__dirname, 'server.pem')) }); let cconn = null; let sconn = null; function doit() { if (cconn && sconn) { cconn.resume(); sconn.resume(); sconn.end(Buffer.alloc(1024*1024)); cconn.end(); } } server.on('secureConnection', function (conn) { conn.on('close', function () { console.log("CLOSE"); }); sconn = conn; doit(); }); server.listen(7000, function () { tls.connect({ ca: fs.readFileSync(path.join(__dirname, 'ca.pem')), port: 7000 }, function () { cconn = this; doit(); }); });
This fixes it:
diff --git a/lib/net.js b/lib/net.js index 0229e450fc..377dd202af 100644 --- a/lib/net.js +++ b/lib/net.js @@ -371,8 +371,8 @@ Socket.prototype._final = function(cb) { }; -function afterShutdown(status, handle) { - var self = handle[owner_symbol]; +function afterShutdown(status) { + var self = this.handle[owner_symbol]; debug('afterShutdown destroyed=%j', self.destroyed, self._readableState);
I can reproduce the issue, both
'end'and'finish'are emitted but not'close'.- addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.
on Dec 13, 2018 cc: @addaleax
- addedtlsIssues and PRs related to the tls subsystem.Issues and PRs related to the tls subsystem.and removednetIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.
on Dec 13, 2018 The first bad commit seems to be e82f67d710.
- added a commit that references this issue
on Dec 26, 2018 - added a commit that references this issue
on Jan 1, 2019 - added a commit that references this issue
on Jan 14, 2019 - added a commit that references this issue
on Feb 8, 2019 - added a commit that references this issue
on Apr 17, 2019 - added a commit that references this issue
on Apr 28, 2019 - added a commit that references this issue
on May 10, 2019 - added a commit that references this issue
on May 16, 2019
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.tlsIssues and PRs related to the tls subsystem.Issues and PRs related to the tls subsystem.
Why does this emit a
closeevent:but this does not emit a close event:
?