From e06fc9458ea3cad1b62aee8004d483aceab228ee Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Mon, 2 Jul 2018 11:57:29 +0200 Subject: [PATCH] fix: ensure onboarding completes after syncing Fix a race condition that could cause the app to think that it is still syncing even after it has completed and as a result being stuck reporting 100% syncing during the onboarding process. `startGrpc` can take some time to fully establish and verify that th connection is set up as we wait for a successful result from a call to `getInfo`. Previously, we would send the `lndSyncing` message to the app only after `startGrpc` was complete. However, if the syncing process had actually completed before `startGrpc` then we would first notify that syncing had completed, only to then notify that it had started after it had already completed. In this fix, we notify the app of `lndSyncing` immediately after the wallet has been unlocked. Fix #525 --- app/zap.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/zap.js b/app/zap.js index f0a7bb81..14086937 100644 --- a/app/zap.js +++ b/app/zap.js @@ -45,7 +45,7 @@ class ZapController { this._registerIpcListeners() // Show the window as soon as the application has finished loading. - this.mainWindow.webContents.on('did-finish-load', async () => { + this.mainWindow.webContents.on('did-finish-load', () => { this.mainWindow.show() this.mainWindow.focus() mainLog.timeEnd('Time until app is visible') @@ -155,9 +155,9 @@ class ZapController { this.startWalletUnlocker() }) - this.neutrino.on('wallet-opened', async () => { + this.neutrino.on('wallet-opened', () => { mainLog.info('Wallet opened') - await this.startGrpc() + this.startGrpc() this.sendMessage('lndSyncing') }) @@ -177,7 +177,7 @@ class ZapController { * Add IPC event listeners... */ _registerIpcListeners() { - ipcMain.on('startLnd', async (event, options = {}) => { + ipcMain.on('startLnd', (event, options = {}) => { // Trim any user supplied strings. const cleanOptions = Object.keys(options).reduce((previous, current) => { previous[current] = @@ -203,7 +203,7 @@ class ZapController { mainLog.debug(' > host:', cleanOptions.host) mainLog.debug(' > cert:', cleanOptions.cert) mainLog.debug(' > macaroon:', cleanOptions.macaroon) - await this.startGrpc() + this.startGrpc() .then(() => this.sendMessage('successfullyCreatedWallet')) .catch(e => { const errors = {}