Skip to content

Commit

Permalink
Catch errors when changing remotes (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager authored Oct 4, 2023
1 parent 364ea20 commit 817019d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ async function connectThroughNode (c, address, socket) {
if (c.rawStream === null) return // Already hole punched

if (c.rawStream.connected) {
c.rawStream.changeRemote(socket, c.connect.payload.udx.id, port, host)
const remoteChanging = c.rawStream.changeRemote(socket, c.connect.payload.udx.id, port, host)

if (remoteChanging) remoteChanging.catch(noop)
} else {
c.rawStream.connect(socket, c.connect.payload.udx.id, port, host)

Expand Down
4 changes: 3 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ module.exports = class Server extends EventEmitter {
hs.rawStream.removeListener('error', autoDestroy)

if (hs.rawStream.connected) {
hs.rawStream.changeRemote(socket, remotePayload.udx.id, port, host)
const remoteChanging = hs.rawStream.changeRemote(socket, remotePayload.udx.id, port, host)

if (remoteChanging) remoteChanging.catch(noop)
} else {
hs.rawStream.connect(socket, remotePayload.udx.id, port, host)

Expand Down

0 comments on commit 817019d

Please sign in to comment.