Skip to content
This repository was archived by the owner on Aug 23, 2019. It is now read-only.

Commit a3e9fab

Browse files
committed
fix: prevent undefined error during a mutual hangup
1 parent 1eb28ca commit a3e9fab

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/dial.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ class Dialer {
267267
}
268268

269269
const muxedConn = this.switch.muxers[key].dialer(conn)
270-
this.switch.muxedConns[b58Id] = {}
271-
this.switch.muxedConns[b58Id].muxer = muxedConn
270+
this.switch.muxedConns[b58Id] = {
271+
muxer: muxedConn
272+
}
272273

273274
muxedConn.once('close', () => {
274275
delete this.switch.muxedConns[b58Id]

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ class Switch extends EE {
110110
this.stats.stop()
111111
series([
112112
(cb) => each(this.muxedConns, (conn, cb) => {
113+
// If the connection was destroyed while we are hanging up, continue
114+
if (!conn) {
115+
return cb()
116+
}
117+
113118
conn.muxer.end((err) => {
114119
// If OK things are fine, and someone just shut down
115120
if (err && err.message !== 'Fatal error: OK') {

0 commit comments

Comments
 (0)