Skip to content

Commit 86c06c0

Browse files
Matt Sergeantaddaleax
Matt Sergeant
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,8 @@ Server.prototype.getConnections = function(cb) {
15581558
const self = this;
15591559

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

15641565
if (!this._usingSlaves) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const net = require('net');
5+
const server = 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)