Skip to content

Commit

Permalink
fix(p2p): prevent xud from crashing when connecting to peer timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
krrprr committed Aug 20, 2019
1 parent 2824482 commit 7932b51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/grpc/GrpcService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ class GrpcService {
case p2pErrorCodes.POOL_CLOSED:
code = status.ABORTED;
break;
case p2pErrorCodes.RESPONSE_TIMEOUT:
code = status.DEADLINE_EXCEEDED;
break;
}

// return a grpc error with the code if we've assigned one, otherwise pass along the caught error as UNKNOWN
Expand Down
2 changes: 1 addition & 1 deletion lib/p2p/Peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ class Peer extends EventEmitter {
const request = PacketType[parseInt(packetId, 10)] || packetId;
const err = errors.RESPONSE_TIMEOUT(request);
this.emitError(err.message);
entry.reject(err.message);
entry.reject(err);
await this.close(DisconnectionReason.ResponseStalling, packetId);
}
}
Expand Down

0 comments on commit 7932b51

Please sign in to comment.