From 6c3d43ead6b18b0797664c09413fa72ef806efb1 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Wed, 5 Sep 2018 10:18:32 +0200 Subject: [PATCH] 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. --- app/lib/lnd/lightning.js | 3 ++- app/lib/lnd/walletUnlocker.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/lib/lnd/lightning.js b/app/lib/lnd/lightning.js index 288ad9f1..7cdc0070 100644 --- a/app/lib/lnd/lightning.js +++ b/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() diff --git a/app/lib/lnd/walletUnlocker.js b/app/lib/lnd/walletUnlocker.js index 318a2450..b712424c 100644 --- a/app/lib/lnd/walletUnlocker.js +++ b/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()