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

Commit

Permalink
fix: preventing uncaught error. Fixes #263
Browse files Browse the repository at this point in the history
  • Loading branch information
pgte committed Jun 8, 2018
1 parent c0eae1e commit 9189844
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/dial.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ function dial (swtch) {
// 3. update the peerInfo that is already stored in the conn
}

openConnInMuxedConn(muxer, (conn) => {
openConnInMuxedConn(muxer, (err, conn) => {
if (err) {
return callback(err)
}
protocolHandshake(conn, protocol, callback)
})
}
Expand Down Expand Up @@ -208,7 +211,13 @@ function dial (swtch) {
}

function openConnInMuxedConn (muxer, cb) {
cb(muxer.newStream())
let s
try {
s = muxer.newStream()
} catch (err) {
return cb(err)
}
cb(null, s)
}

function protocolHandshake (conn, protocol, cb) {
Expand Down

0 comments on commit 9189844

Please sign in to comment.