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
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"@sentry/node": "~7.59.3",
"fastify": "~5.6.2",
"fastify-plugin": "~5.1.0",
"http-errors": "~2.0.0",
"nested-env-schema": "~1.4.0",
"nested-env-schema": "~1.4.1",
"yaml": "~2.5.0",
"zod": "~4.1.12"
},
Expand All @@ -46,7 +45,6 @@
},
"devDependencies": {
"@types/chai": "~4.3.3",
"@types/http-errors": "~2.0.1",
"@types/mocha": "~9.1.1",
"@types/node": "~22.13.5",
"@types/sinon": "~17.0.3",
Expand Down
21 changes: 5 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import fastify from 'fastify';
import fastifyAutoload from '@fastify/autoload';
import { FastifyError } from '@fastify/error';
import fastifyHelmet from '@fastify/helmet';
import fastifySensible from '@fastify/sensible';
import fastifySensible, { HttpError } from '@fastify/sensible';
import fastifySwagger from '@fastify/swagger';
import fastifySwaggerUi from '@fastify/swagger-ui';
import httpErrors from 'http-errors';

export const server = async () => {
const app = fastify({
Expand All @@ -34,7 +33,7 @@ export const server = async () => {
await app.register(fastifyHelmet);

app.setErrorHandler((error, request, reply) => {
if (error instanceof httpErrors.HttpError) {
if (error instanceof HttpError) {
return error;
}

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
env,
environment,
isProduction,
isTest,
product,
service,
version,
Expand Down Expand Up @@ -34,14 +35,14 @@
}

app.decorate('error', {
capture: (err: any, context?: Record<string, unknown>) => {

Check warning on line 38 in src/plugins/error.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 38 in src/plugins/error.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
tracer.startActiveSpan('error:capture', (span) => {
if (isErrorTrackingEnabled) {
withScope((scope) => {
scope.setContext('error', { message: err.message, ...context });
captureException(err);
});
} else {
} else if (!isTest) {
console.error(err);
}

Expand Down
5 changes: 1 addition & 4 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ export const meter = api.metrics.getMeter('default');
process.on('SIGTERM', () => {
sdk
.shutdown()
.then(
() => console.log('Telemetry shut down successfully'),
() => console.log('Telemetry shut down failed'),
)
.catch(() => console.log('Telemetry shut down failed'))
.finally(() => process.exit(0));
});
Loading