From 0a80e3e39d0c78dacce69629bf4c25166f93a53e Mon Sep 17 00:00:00 2001 From: Sam Keen Date: Wed, 17 May 2023 14:21:00 +0100 Subject: [PATCH] fix(governance): avoid unknown pubkey causing validator page error (#3755) --- apps/governance/src/app.tsx | 21 +++++++++++++++---- .../routes/staking/node/nodes-container.tsx | 19 +++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/apps/governance/src/app.tsx b/apps/governance/src/app.tsx index e11be4041..74a917d14 100644 --- a/apps/governance/src/app.tsx +++ b/apps/governance/src/app.tsx @@ -211,24 +211,37 @@ const AppContainer = () => { enabled: true, environment: VEGA_ENV, release: GIT_COMMIT_HASH, - beforeSend(event) { + beforeSend(event, hint) { + const error = hint?.originalException; + const errorIsString = typeof error === 'string'; + const errorIsObject = error instanceof Error; const requestUrl = event.request?.url; const transaction = event.transaction; + if ( + (errorIsString && error.includes('failed to get party ID')) || + (errorIsObject && + error?.message?.includes('failed to get party ID')) + ) { + // This error is caused by a pubkey making an API request before + // it has interacted with the chain. This isn't needed in Sentry. + return null; + } + const updatedRequest = - requestUrl && requestUrl.includes('/test?') + requestUrl && requestUrl.includes('/claim?') ? { ...event.request, url: removeQueryParams(requestUrl) } : event.request; const updatedTransaction = - transaction && transaction.includes('/test?') + transaction && transaction.includes('/claim?') ? removeQueryParams(transaction) : transaction; const updatedBreadcrumbs = event.breadcrumbs?.map((breadcrumb) => { if ( breadcrumb.type === 'navigation' && - breadcrumb.data?.to?.includes('/test?') + breadcrumb.data?.to?.includes('/claim?') ) { return { ...breadcrumb, diff --git a/apps/governance/src/routes/staking/node/nodes-container.tsx b/apps/governance/src/routes/staking/node/nodes-container.tsx index f6acd6892..3c9e2cb58 100644 --- a/apps/governance/src/routes/staking/node/nodes-container.tsx +++ b/apps/governance/src/routes/staking/node/nodes-container.tsx @@ -1,4 +1,3 @@ -import { useEffect, useState } from 'react'; import { ENV } from '../../../config'; import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; @@ -39,21 +38,9 @@ export const NodeContainer = ({ } : undefined, }, + errorPolicy: 'all', }); - const [isRefetching, setIsRefetching] = useState(false); - - useEffect(() => { - if (error && error.message.includes('failed to get party for ID')) { - setIsRefetching(true); - // The API errors if there is a pubkey, but it hasn't interacted with the - // chain before. In that case, retry the query with empty pubKey - refetch({ - partyId: '', - }).finally(() => setIsRefetching(false)); - } - }, [error, refetch, delegationsPagination]); - const { data: previousEpochData } = usePreviousEpochQuery({ variables: { epochId: (Number(data?.epoch.id) - 1).toString(), @@ -63,7 +50,7 @@ export const NodeContainer = ({ useRefreshAfterEpoch(data?.epoch.timestamps.expiry, refetch); - if (error && !isRefetching) { + if (error && !error.message.includes('failed to get party for ID')) { return (
@@ -75,7 +62,7 @@ export const NodeContainer = ({
     );
   }
 
-  if (loading || isRefetching) {
+  if (loading) {
     return (