aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Miller <danjm.com@gmail.com>2018-12-07 03:42:57 +0800
committerDan Miller <danjm.com@gmail.com>2018-12-07 03:43:24 +0800
commit246dcf689c7e14bd9eab997fd81fc7b4a8914007 (patch)
tree1e9c0c603e28a174201db5d4320b4d4279a51ea5
parentd1996509deccd98d7ffa4cc360dc96c5392879d3 (diff)
downloadtangerine-wallet-browser-246dcf689c7e14bd9eab997fd81fc7b4a8914007.tar
tangerine-wallet-browser-246dcf689c7e14bd9eab997fd81fc7b4a8914007.tar.gz
tangerine-wallet-browser-246dcf689c7e14bd9eab997fd81fc7b4a8914007.tar.bz2
tangerine-wallet-browser-246dcf689c7e14bd9eab997fd81fc7b4a8914007.tar.lz
tangerine-wallet-browser-246dcf689c7e14bd9eab997fd81fc7b4a8914007.tar.xz
tangerine-wallet-browser-246dcf689c7e14bd9eab997fd81fc7b4a8914007.tar.zst
tangerine-wallet-browser-246dcf689c7e14bd9eab997fd81fc7b4a8914007.zip
Fix race condition in network controller lookup() method.
-rw-r--r--app/scripts/controllers/network/network.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js
index b459b8013..1a251bce1 100644
--- a/app/scripts/controllers/network/network.js
+++ b/app/scripts/controllers/network/network.js
@@ -105,12 +105,18 @@ module.exports = class NetworkController extends EventEmitter {
if (!this._provider) {
return log.warn('NetworkController - lookupNetwork aborted due to missing provider')
}
- var { type } = this.providerStore.getState()
+ const { type } = this.providerStore.getState()
const ethQuery = new EthQuery(this._provider)
+ const initialNetwork = this.getNetworkState()
ethQuery.sendAsync({ method: 'net_version' }, (err, network) => {
- if (err) return this.setNetworkState('loading')
- log.info('web3.getNetwork returned ' + network)
- this.setNetworkState(network, type)
+ const currentNetwork = this.getNetworkState()
+ if (initialNetwork === currentNetwork) {
+ if (err) {
+ return this.setNetworkState('loading')
+ }
+ log.info('web3.getNetwork returned ' + network)
+ this.setNetworkState(network, type)
+ }
})
}