From 00c212b847f2f0087aadbb85f876a245138b3f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Tue, 6 Aug 2024 18:33:46 +0200 Subject: [PATCH] fix: intermittent e2e failures (#15) Co-authored-by: Ibrahim <109112750+blockqa@users.noreply.github.com> Co-authored-by: bferenc <117105626+bferenc@users.noreply.github.com> --- src/background/services/network/NetworkService.ts | 13 +++++++++++-- tsconfig.json | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/background/services/network/NetworkService.ts b/src/background/services/network/NetworkService.ts index fcd9ec1be..654135595 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 45a4873e1..d1476f194 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,