diff --git a/src/background/services/network/NetworkService.ts b/src/background/services/network/NetworkService.ts index fcd9ec1b..65413559 100644 --- a/src/background/services/network/NetworkService.ts +++ b/src/background/services/network/NetworkService.ts @@ -326,7 +326,8 @@ export class NetworkService implements OnLock, OnStorageReady { // At this point the chainlist from Glacier should already be available, // as it is fetched when service worker starts (so before extension is unlocked). // If it isn't available yet, we'll use the list cached in the storage. - const chainlist = await Promise.race([ + + const chainlist = await Promise.any([ this._chainListFetched.promisify(), this._getCachedChainList(), ]); @@ -358,7 +359,15 @@ export class NetworkService implements OnLock, OnStorageReady { } private async _getCachedChainList(): Promise { - return this.storageService.load(NETWORK_LIST_STORAGE_KEY); + const networkList = await this.storageService.load( + NETWORK_LIST_STORAGE_KEY + ); + + if (!networkList) { + throw new Error('No networks cached'); + } + + return networkList; } private _getPchainNetwork(isTestnet: boolean): Network { diff --git a/tsconfig.json b/tsconfig.json index 45a4873e..d1476f19 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ "sourceMap": true, "jsx": "react-jsx", "esModuleInterop": true, - "lib": ["es2015", "dom"], + "lib": ["es2015", "es2021", "dom"], "experimentalDecorators": true, "emitDecoratorMetadata": true, "allowSyntheticDefaultImports": true,