Skip to content

Commit f268757

Browse files
committed
fix(sentry): Pass HttpAdapterHost to SentryGlobalFilter
Because: * SentryGlobalFilter was instantiated without arguments, causing applicationRef to be undefined * When exceptions occurred, filter crashed on applicationRef.isHeadersSent() * Crashed filter left requests hanging without response, preventing Pub/Sub message acknowledgement * Unacked messages caused infinite redelivery loop (RP event distribution delays spiked to 2.31 days) This commit: * Passes httpAdapter from HttpAdapterHost to SentryGlobalFilter constructor in fxa-graphql-api, fxa-event-broker, and fxa-admin-server * Ensures filter can handle exceptions without crashing * Allows proper HTTP responses to Pub/Sub push endpoints so messages are acknowledged Closes #FXA-13031
1 parent 433d57a commit f268757

6 files changed

Lines changed: 18 additions & 15 deletions

File tree

packages/fxa-admin-server/src/app.module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { EventLoggingModule } from './event-logging/event-logging.module';
2727
import { GqlModule } from './gql/gql.module';
2828
import { NewslettersModule } from './newsletters/newsletters.module';
2929
import { SubscriptionModule } from './subscriptions/subscriptions.module';
30-
import { LOGGER_PROVIDER } from '@fxa/shared/log';
3130

3231
const version = getVersionInfo(__dirname);
3332

packages/fxa-admin-server/src/main.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
import './monitoring';
88

99
import { NestApplicationOptions } from '@nestjs/common';
10-
import { NestFactory } from '@nestjs/core';
10+
import { HttpAdapterHost, NestFactory } from '@nestjs/core';
1111
import { NestExpressApplication } from '@nestjs/platform-express';
1212
import { allowlistGqlQueries } from 'fxa-shared/nestjs/gql/gql-allowlist';
1313
import helmet from 'helmet';
14-
import { AppModule } from './app.module';
15-
import Config, { AppConfig } from './config';
1614
import cors from 'cors';
17-
import { SentryGlobalFilter } from '@sentry/nestjs/setup';
1815
import * as Sentry from '@sentry/nestjs';
16+
import { SentryGlobalFilter } from '@sentry/nestjs/setup';
17+
18+
import { AppModule } from './app.module';
19+
import Config, { AppConfig } from './config';
1920

2021
const appConfig = Config.getProperties() as AppConfig;
2122

@@ -29,8 +30,9 @@ async function bootstrap() {
2930
nestConfig
3031
);
3132

32-
// As of sentry v9, this should handle both regular requests and graphql requests.
33-
app.useGlobalFilters(new SentryGlobalFilter());
33+
// Register Sentry exception filter with proper HttpAdapterHost
34+
const { httpAdapter } = app.get(HttpAdapterHost);
35+
app.useGlobalFilters(new SentryGlobalFilter(httpAdapter));
3436

3537
app.use(
3638
cors({

packages/fxa-event-broker/src/app.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
import { Module } from '@nestjs/common';
5-
import { ConfigModule, ConfigService } from '@nestjs/config';
5+
import { ConfigModule } from '@nestjs/config';
66
import { ScheduleModule } from '@nestjs/schedule';
77
import { HealthModule } from 'fxa-shared/nestjs/health/health.module';
88
import { LoggerModule } from 'fxa-shared/nestjs/logger/logger.module';
9-
import { MozLoggerService } from 'fxa-shared/nestjs/logger/logger.service';
109
import { MetricsFactory } from 'fxa-shared/nestjs/metrics.service';
1110
import { getVersionInfo } from 'fxa-shared/nestjs/version';
1211

packages/fxa-event-broker/src/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { SentryGlobalFilter } from '@sentry/nestjs/setup';
1111

1212
import { NestApplicationOptions } from '@nestjs/common';
1313
import { ConfigService } from '@nestjs/config';
14-
import { NestFactory } from '@nestjs/core';
14+
import { HttpAdapterHost, NestFactory } from '@nestjs/core';
1515
import mozLog from 'mozlog';
1616

1717
import { initTracing } from 'fxa-shared/tracing/node-tracing';
@@ -34,7 +34,9 @@ async function bootstrap() {
3434
const config: ConfigService<AppConfig> = app.get(ConfigService);
3535
const proxyConfig = config.get('proxy') as AppConfig['proxy'];
3636

37-
app.useGlobalFilters(new SentryGlobalFilter());
37+
// Register Sentry exception filter with proper HttpAdapterHost
38+
const { httpAdapter } = app.get(HttpAdapterHost);
39+
app.useGlobalFilters(new SentryGlobalFilter(httpAdapter));
3840

3941
// Starts listening for shutdown hooks
4042
app.enableShutdownHooks();

packages/fxa-graphql-api/src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const version = getVersionInfo(__dirname);
5252
extraHealthData: () => db.dbHealthCheck(),
5353
}),
5454
}),
55-
CustomsModule
55+
CustomsModule,
5656
],
5757
controllers: [],
5858
providers: [

packages/fxa-graphql-api/src/main.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { StatsDService } from '@fxa/shared/metrics/statsd';
1616
import helmet from 'helmet';
1717

1818
import { NestApplicationOptions } from '@nestjs/common';
19-
import { NestFactory } from '@nestjs/core';
19+
import { HttpAdapterHost, NestFactory } from '@nestjs/core';
2020
import { NestExpressApplication } from '@nestjs/platform-express';
2121

2222
import { AppModule } from './app.module';
@@ -34,8 +34,9 @@ async function bootstrap() {
3434
nestConfig
3535
);
3636

37-
// As of sentry v9, this should handle both regular requests and graphql requests.
38-
app.useGlobalFilters(new SentryGlobalFilter());
37+
// Register Sentry exception filter with proper HttpAdapterHost
38+
const { httpAdapter } = app.get(HttpAdapterHost);
39+
app.useGlobalFilters(new SentryGlobalFilter(httpAdapter));
3940

4041
// Configure allowlisting of gql queries
4142
app.use(bodyParser.json());

0 commit comments

Comments
 (0)