Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/payments/next/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ const nextConfig = {
'@googleapis/androidpublisher',
'@googlemaps/google-maps-services-js',
'@grpc',
'@nestjs/apollo',
Comment thread
vpomerleau marked this conversation as resolved.
'@nestjs/common',
'@nestjs/config',
'@nestjs/core',
'@nestjs/graphql',
'@nestjs/mapped-types',
'@nestjs/passport',
'@nestjs/platform-express',
Expand Down
11 changes: 0 additions & 11 deletions libs/shared/sentry-nest/src/lib/reporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { ignoreError, isAuthServerError } from './reporting';
import { GraphQLError } from 'graphql';
import { HttpException } from '@nestjs/common';

describe('detects auth server error', () => {
Expand Down Expand Up @@ -65,16 +64,6 @@ describe('error ignore policies', () => {
).toBeTruthy();
});

it('should ignore apollo errors', () => {
// Apollo errors should be sent to clients and we don't report them.
const err = new GraphQLError('BOOM', {
extensions: {
code: 'BAD_REQUEST',
},
});
expect(ignoreError(err)).toBeTruthy();
});

it('should ignore non 500 errors', () => {
// Non-500s are expected responses for clients and we don't report them.
expect(ignoreError(new HttpException('Not Found', 404))).toBeTruthy();
Expand Down
45 changes: 1 addition & 44 deletions libs/shared/sentry-nest/src/lib/reporting.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import * as Sentry from '@sentry/nestjs';
import { ExecutionContext, HttpException } from '@nestjs/common';
import { GqlContextType, GqlExecutionContext } from '@nestjs/graphql';
import { ApolloServerErrorCode } from '@apollo/server/errors';

import { GraphQLError } from 'graphql';
import { HttpException } from '@nestjs/common';
import { Message } from '@aws-sdk/client-sqs';
import { Request } from 'express';

Expand All @@ -27,26 +23,10 @@ export function captureSqsError(err: Error, message?: Message): void {
});
}

/**
* Determine if an error is an ApolloError.
* Prior to GQL 16.8 and apollo-server 4.9.3, we used ApolloError from apollo-server.
* Now, we populate fields on GraphQL error to mimic the previous state of ApolloError.
*/
export function isApolloError(err: Error): boolean {
if (err instanceof GraphQLError) {
const code = err.extensions?.['code'];
if (typeof code === 'string') {
return Object.keys(ApolloServerErrorCode).includes(code);
}
}
return false;
}

/** Indicates if error should be sent to Sentry */
export function ignoreError(err: any): boolean {
return (
isAuthServerError(err) ||
isApolloError(err) ||
isOriginallyHttpError(err) ||
(isHttpException(err) && !isInternalServerError(err))
);
Expand Down Expand Up @@ -127,26 +107,3 @@ export function reportRequestException(
exception.reported = true;
});
}

// TODO: Dead code?
export function processException(context: ExecutionContext, exception: Error) {
// First determine what type of a request this is
let request: Request | undefined;
let gqlExec: GqlExecutionContext | undefined;
if (context.getType() === 'http') {
request = context.switchToHttp().getRequest();
} else if (context.getType<GqlContextType>() === 'graphql') {
gqlExec = GqlExecutionContext.create(context);
request = gqlExec.getContext().req;
}
const excContexts: ExtraContext[] = [];
if (gqlExec) {
const info = gqlExec.getInfo();
excContexts.push({
name: 'graphql',
fieldData: { fieldName: info.fieldName, path: info.path },
});
}

reportRequestException(exception, excContexts, request);
}
1 change: 0 additions & 1 deletion libs/shared/sentry/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

export * from './lib/nest/sentry.plugin';
export * from './lib/nest/sentry.constants';
export * from './lib/reporting';
export * from './lib/node';
Expand Down
127 changes: 0 additions & 127 deletions libs/shared/sentry/src/lib/nest/sentry.plugin.ts

This file was deleted.

11 changes: 0 additions & 11 deletions libs/shared/sentry/src/lib/reporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { ignoreError, isAuthServerError } from './reporting';
import { GraphQLError } from 'graphql';
import { HttpException } from '@nestjs/common';

describe('detects auth server error', () => {
Expand Down Expand Up @@ -64,16 +63,6 @@ describe('error ignore policies', () => {
).toBeTruthy();
});

it('should ignore apollo errors', () => {
// Apollo errors should be sent to clients and we don't report them.
const err = new GraphQLError('BOOM', {
extensions: {
code: 'BAD_REQUEST',
},
});
expect(ignoreError(err)).toBeTruthy();
});

it('should ignore non 500 errors', () => {
// Non-500s are expected responses for clients and we don't report them.
expect(ignoreError(new HttpException('Not Found', 404))).toBeTruthy();
Expand Down
43 changes: 1 addition & 42 deletions libs/shared/sentry/src/lib/reporting.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { ExecutionContext, HttpException } from '@nestjs/common';
import { ApolloServerErrorCode } from '@apollo/server/errors';
import { GraphQLError } from 'graphql';
import { GqlContextType, GqlExecutionContext } from '@nestjs/graphql';
import { HttpException } from '@nestjs/common';
import * as Sentry from '@sentry/node';
import { Message } from '@aws-sdk/client-sqs';
import { Request } from 'express';
Expand Down Expand Up @@ -33,27 +30,11 @@ export function tagFxaName(data: any, name?: string) {
export function ignoreError(err: any): boolean {
return (
isAuthServerError(err) ||
isApolloError(err) ||
isOriginallyHttpError(err) ||
(isHttpException(err) && !isInternalServerError(err))
);
}

/**
* Determine if an error is an ApolloError.
* Prior to GQL 16.8 and apollo-server 4.9.3, we used ApolloError from apollo-server.
* Now, we populate fields on GraphQL error to mimic the previous state of ApolloError.
*/
export function isApolloError(err: Error): boolean {
if (err instanceof GraphQLError) {
const code = err.extensions?.code;
if (typeof code === 'string') {
return Object.keys(ApolloServerErrorCode).includes(code);
}
}
return false;
}

/**
* Determine if an error originates from auth-server. Auth server responds with error
* codes and numbers, and client applications handle these states accordingly. These
Expand Down Expand Up @@ -145,25 +126,3 @@ export function reportRequestException(
exception.reported = true;
});
}

export function processException(context: ExecutionContext, exception: Error) {
// First determine what type of a request this is
let request: Request | undefined;
let gqlExec: GqlExecutionContext | undefined;
if (context.getType() === 'http') {
request = context.switchToHttp().getRequest();
} else if (context.getType<GqlContextType>() === 'graphql') {
gqlExec = GqlExecutionContext.create(context);
request = gqlExec.getContext().req;
}
const excContexts: ExtraContext[] = [];
if (gqlExec) {
const info = gqlExec.getInfo();
excContexts.push({
name: 'graphql',
fieldData: { fieldName: info.fieldName, path: info.path },
});
}

reportRequestException(exception, excContexts, request);
}
1 change: 0 additions & 1 deletion libs/vendored/jwtool/src/lib/jwtool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import * as crypto from 'crypto';
import * as fs from 'fs';
import fetch from 'node-fetch';

import { jwk2pem, pem2jwk } from '@fxa/shared/pem-jwk';

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"license": "MPL-2.0",
"dependencies": {
"@apollo/client": "^3.11.1",
"@apollo/server": "^4.13.0",
"@aws-sdk/client-s3": "^3.973.0",
"@aws-sdk/client-sns": "^3.973.0",
"@aws-sdk/client-sqs": "^3.973.0",
Expand All @@ -59,11 +58,9 @@
"@googlemaps/google-maps-services-js": "^3.4.0",
"@grpc/grpc-js": "^1.11.1",
"@mozilla/glean": "^5.0.8",
"@nestjs/apollo": "^12.2.1",
"@nestjs/common": "^10.4.5",
"@nestjs/config": "^3.3.0",
"@nestjs/core": "^10.4.1",
"@nestjs/graphql": "^12.2.0",
"@nestjs/mapped-types": "^2.0.5",
"@nestjs/passport": "^10.0.3",
Comment thread
vpomerleau marked this conversation as resolved.
"@nestjs/platform-express": "^10.4.18",
Expand Down Expand Up @@ -233,6 +230,7 @@
"@types/module-alias": "^2",
"@types/mysql": "^2",
"@types/node": "^22.13.5",
"@types/node-fetch": "^2.6.12",
"@types/nodemailer": "^7.0.4",
"@types/passport": "^1.0.6",
"@types/passport-http-bearer": "^1.0.36",
Expand Down
Loading
Loading