From 800d4150c00b85200af5cf3bec24f85ec75c6aeb Mon Sep 17 00:00:00 2001 From: Maxwell Lasky Date: Mon, 12 Nov 2018 17:29:47 -0700 Subject: [PATCH] updates nodeStorageActions.js --- app/actions/nodeStorageActions.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/actions/nodeStorageActions.js b/app/actions/nodeStorageActions.js index 3d9cf50cc..0bf42a613 100644 --- a/app/actions/nodeStorageActions.js +++ b/app/actions/nodeStorageActions.js @@ -61,8 +61,12 @@ export const getRPCEndpoint = async ( const goodNodes = nodes.filter( n => n.client.lastSeenHeight >= heightThreshold ) - const randomlySelectedRPCUrl = - goodNodes[random(goodNodes.length) - 1].client.net + let randomIndex = random(goodNodes.length) + if (randomIndex === goodNodes.length) { + // eslint-disable-next-line + randomIndex-- + } + const randomlySelectedRPCUrl = goodNodes[randomIndex].client.net cachedRPCUrl[net] = randomlySelectedRPCUrl return randomlySelectedRPCUrl } catch (error) {