Skip to content

Commit 86c06c0

Browse files
Matt Sergeantaddaleax
authored andcommitted
async-hooks,net: ensure asyncId=null if no handle
If the .listen() hasn't been called on the server, there is no handle object. In this case use null as the triggerAsyncId. Fixes: #13548 PR-URL: #13938 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
1 parent 2eabd92 commit 86c06c0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎lib/net.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,8 @@ Server.prototype.getConnections = function(cb){
15581558
constself=this;
15591559

15601560
functionend(err,connections){
1561-
nextTick(self[async_id_symbol],cb,err,connections);
1561+
constasyncId=self._handle ? self[async_id_symbol] : null;
1562+
nextTick(asyncId,cb,err,connections);
15621563
}
15631564

15641565
if(!this._usingSlaves){
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
constcommon=require('../common');
4+
constnet=require('net');
5+
constserver=net.createServer();
6+
7+
// This test was based on an error raised by Haraka.
8+
// It caused server.getConnections to raise an exception.
9+
// Ref: https://github.com/haraka/Haraka/pull/1951
10+
11+
server.getConnections(common.mustCall());

0 commit comments

Comments
(0)