aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorThomas Huang <tmashuang@users.noreply.github.com>2018-12-08 06:49:00 +0800
committerGitHub <noreply@github.com>2018-12-08 06:49:00 +0800
commit575fb607c3b8deea831aa28293303991b3f6be29 (patch)
tree390699ef8c6b6ad617c094729de9adc65b23bc11 /app
parent347b26f02850093cec6d3c1a29ea2d09bf5e5c93 (diff)
parent246dcf689c7e14bd9eab997fd81fc7b4a8914007 (diff)
downloadtangerine-wallet-browser-575fb607c3b8deea831aa28293303991b3f6be29.tar
tangerine-wallet-browser-575fb607c3b8deea831aa28293303991b3f6be29.tar.gz
tangerine-wallet-browser-575fb607c3b8deea831aa28293303991b3f6be29.tar.bz2
tangerine-wallet-browser-575fb607c3b8deea831aa28293303991b3f6be29.tar.lz
tangerine-wallet-browser-575fb607c3b8deea831aa28293303991b3f6be29.tar.xz
tangerine-wallet-browser-575fb607c3b8deea831aa28293303991b3f6be29.tar.zst
tangerine-wallet-browser-575fb607c3b8deea831aa28293303991b3f6be29.zip
Merge pull request #5892 from MetaMask/fix-net-version-race-condition
Fix race condition in network controller lookup() method.
Diffstat (limited to 'app')
-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)
+ }
})
}