fix(governance): avoid unknown pubkey causing validator page error (#3755)

This commit is contained in:
Sam Keen 2023-05-17 14:21:00 +01:00 committed by GitHub
parent 7b8d9dc94b
commit 0a80e3e39d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 20 deletions

View File

@ -211,24 +211,37 @@ const AppContainer = () => {
enabled: true, enabled: true,
environment: VEGA_ENV, environment: VEGA_ENV,
release: GIT_COMMIT_HASH, 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 requestUrl = event.request?.url;
const transaction = event.transaction; 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 = const updatedRequest =
requestUrl && requestUrl.includes('/test?') requestUrl && requestUrl.includes('/claim?')
? { ...event.request, url: removeQueryParams(requestUrl) } ? { ...event.request, url: removeQueryParams(requestUrl) }
: event.request; : event.request;
const updatedTransaction = const updatedTransaction =
transaction && transaction.includes('/test?') transaction && transaction.includes('/claim?')
? removeQueryParams(transaction) ? removeQueryParams(transaction)
: transaction; : transaction;
const updatedBreadcrumbs = event.breadcrumbs?.map((breadcrumb) => { const updatedBreadcrumbs = event.breadcrumbs?.map((breadcrumb) => {
if ( if (
breadcrumb.type === 'navigation' && breadcrumb.type === 'navigation' &&
breadcrumb.data?.to?.includes('/test?') breadcrumb.data?.to?.includes('/claim?')
) { ) {
return { return {
...breadcrumb, ...breadcrumb,

View File

@ -1,4 +1,3 @@
import { useEffect, useState } from 'react';
import { ENV } from '../../../config'; import { ENV } from '../../../config';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit'; import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
import { useVegaWallet } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet';
@ -39,21 +38,9 @@ export const NodeContainer = ({
} }
: undefined, : 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({ const { data: previousEpochData } = usePreviousEpochQuery({
variables: { variables: {
epochId: (Number(data?.epoch.id) - 1).toString(), epochId: (Number(data?.epoch.id) - 1).toString(),
@ -63,7 +50,7 @@ export const NodeContainer = ({
useRefreshAfterEpoch(data?.epoch.timestamps.expiry, refetch); useRefreshAfterEpoch(data?.epoch.timestamps.expiry, refetch);
if (error && !isRefetching) { if (error && !error.message.includes('failed to get party for ID')) {
return ( return (
<Callout intent={Intent.Danger} title={t('Something went wrong')}> <Callout intent={Intent.Danger} title={t('Something went wrong')}>
<pre> <pre>
@ -75,7 +62,7 @@ export const NodeContainer = ({
); );
} }
if (loading || isRefetching) { if (loading) {
return ( return (
<Splash> <Splash>
<SplashLoader /> <SplashLoader />