Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit 8bfb19a

Browse files
vasco-santosjacobheun
authored andcommitted
fix: catch thrown maConn errors in listener
1 parent d630b32 commit 8bfb19a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/listener.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ module.exports = ({ handler, upgrader }, options = {}) => {
1414
const listener = new EventEmitter()
1515

1616
const server = createServer(options, async (stream) => {
17-
const maConn = toConnection(stream)
17+
let maConn, conn
1818

19-
log('new inbound connection %s', maConn.remoteAddr)
20-
21-
let conn
2219
try {
20+
maConn = toConnection(stream)
21+
log('new inbound connection %s', maConn.remoteAddr)
2322
conn = await upgrader.upgradeInbound(maConn)
2423
} catch (err) {
2524
log.error('inbound connection failed to upgrade', err)
26-
return maConn.close()
25+
return maConn && maConn.close()
2726
}
2827

2928
log('inbound connection %s upgraded', maConn.remoteAddr)

0 commit comments

Comments
 (0)