Browse Source

fix(grpc): close connection after failed connect

The gRPC Client waitForReady call waits for a specified time frame and
either resolves or rejects depending on wether or not a successful
connection was established within the given time frame. If the
connection attempt failed gRPC will still continue to attempt to
establish the connection endlessly.

In this commit we explicitly close the client connection after the
connect deadline has been exceeded to prevent gRPC from trying to
connect.
renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
parent
commit
6c3d43ead6
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 3
      app/lib/lnd/lightning.js
  2. 3
      app/lib/lnd/walletUnlocker.js

3
app/lib/lnd/lightning.js

@ -93,8 +93,9 @@ class Lightning {
// Wait for the gRPC connection to be established.
return new Promise((resolve, reject) => {
grpc.waitForClientReady(this.service, getDeadline(2), err => {
this.service.waitForReady(getDeadline(2), err => {
if (err) {
this.service.close()
return reject(err)
}
return resolve()

3
app/lib/lnd/walletUnlocker.js

@ -74,8 +74,9 @@ class WalletUnlocker {
// Wait for the gRPC connection to be established.
return new Promise((resolve, reject) => {
grpc.waitForClientReady(this.service, getDeadline(2), err => {
this.service.waitForReady(getDeadline(2), err => {
if (err) {
this.service.close()
return reject(err)
}
return resolve()

Loading…
Cancel
Save