From 0e640e990757ff538739870d2a07ee4968597079 Mon Sep 17 00:00:00 2001 From: Tom Smithhisler Date: Wed, 8 Jan 2025 16:52:51 -0500 Subject: [PATCH] fix(instrumentation-fastify): add missing module export fastify v4.x+ exports an object named `errorCodes` as both a property of the default export and as a named export. The export is documented at https://github.com/fastify/fastify/blob/4.x/docs/Reference/Errors.md?plain=1#L236. This closes #2027. --- .../src/instrumentation.ts | 3 +++ .../test/instrumentation.test.ts | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts index 72d8b8c9b7..32fc01dd46 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -27,6 +27,7 @@ import type { FastifyInstance, FastifyRequest, FastifyReply, + FastifyErrorCodes, } from 'fastify'; import { hooksNamesToWrap } from './constants'; import { @@ -185,6 +186,7 @@ export class FastifyInstrumentation extends InstrumentationBase FastifyInstance; + errorCodes: FastifyErrorCodes; }): () => FastifyInstance { const instrumentation = this; @@ -198,6 +200,7 @@ export class FastifyInstrumentation extends InstrumentationBase { }, }); }); + + it('should expose errorCodes', async () => { + assert.ok(Fastify.errorCodes); + assert.strictEqual(typeof Fastify.errorCodes, 'object'); + assert.ok('FST_ERR_NOT_FOUND' in Fastify.errorCodes); + }) });