mirror of
https://github.com/graphql-hive/console
synced 2026-05-23 09:08:34 +00:00
Do not capture GraphQLError exceptions (#653)
This commit is contained in:
parent
9ac112db1e
commit
935cc59f6a
2 changed files with 10 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import * as Sentry from '@sentry/node';
|
||||
import type { Span } from '@sentry/types';
|
||||
import { GraphQLError } from 'graphql';
|
||||
|
||||
export type SentryContext = Parameters<Span['startChild']>[0] & {
|
||||
captureException?: boolean;
|
||||
|
|
@ -45,7 +46,9 @@ export function sentry(name: string, addToContext?: (...args: any[]) => SentryCo
|
|||
return Promise.resolve(result);
|
||||
},
|
||||
error => {
|
||||
Sentry.captureException(error);
|
||||
if (!(error instanceof GraphQLError)) {
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
span.setStatus('internal_error');
|
||||
span.finish();
|
||||
return Promise.reject(error);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify/dist/trpc-serve
|
|||
import { createRegistry, LogFn, Logger } from '@hive/api';
|
||||
import { createStorage as createPostgreSQLStorage, createConnectionString } from '@hive/storage';
|
||||
import got from 'got';
|
||||
import { stripIgnoredCharacters } from 'graphql';
|
||||
import { GraphQLError, stripIgnoredCharacters } from 'graphql';
|
||||
import * as Sentry from '@sentry/node';
|
||||
import { Dedupe, ExtraErrorData } from '@sentry/integrations';
|
||||
import { internalApiRouter, createContext } from './api';
|
||||
|
|
@ -30,7 +30,7 @@ export async function main() {
|
|||
if (env.sentry) {
|
||||
Sentry.init({
|
||||
serverName: 'api',
|
||||
enabled: !!env.sentry,
|
||||
enabled: true,
|
||||
environment: env.environment,
|
||||
dsn: env.sentry.dsn,
|
||||
tracesSampleRate: 1,
|
||||
|
|
@ -71,6 +71,10 @@ export async function main() {
|
|||
|
||||
const errorObj = error instanceof Error ? error : errorLike instanceof Error ? errorLike : null;
|
||||
|
||||
if (errorObj instanceof GraphQLError) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (errorObj instanceof Error) {
|
||||
Sentry.captureException(errorObj, {
|
||||
level,
|
||||
|
|
|
|||
Loading…
Reference in a new issue