Skip to content

Commit

Permalink
fix(fastify): Make sure consturctor patching works with esm
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Aug 10, 2023
1 parent 4f11245 commit d052a1b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ export class FastifyInstrumentation extends InstrumentationBase {
}

private _patchConstructor(
original: () => FastifyInstance
): () => FastifyInstance {
moduleExports: { fastify: () => FastifyInstance },
): () => FastifyInstance {
const instrumentation = this;
this._diag.debug('Patching fastify constructor function');

function fastify(this: FastifyInstance, ...args: any) {
const app: FastifyInstance = original.apply(this, args);
const app: FastifyInstance = moduleExports.fastify.apply(this, args);
app.addHook('onRequest', instrumentation._hookOnRequest());
app.addHook('preHandler', instrumentation._hookPreHandler());

Expand Down

0 comments on commit d052a1b

Please sign in to comment.