Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fastify's _patchConstructor causing errorCodes to be inaccessible #2027

Open
paskahlisanjas opened this issue Mar 20, 2024 · 0 comments
Open

Comments

@paskahlisanjas
Copy link

private _patchConstructor(moduleExports: {
fastify: () => FastifyInstance;
}): () => FastifyInstance {
const instrumentation = this;
this._diag.debug('Patching fastify constructor function');
function fastify(this: FastifyInstance, ...args: any) {
const app: FastifyInstance = moduleExports.fastify.apply(this, args);
app.addHook('onRequest', instrumentation._hookOnRequest());
app.addHook('preHandler', instrumentation._hookPreHandler());
instrumentation._wrap(app, 'addHook', instrumentation._wrapAddHook());
return app;
}
fastify.fastify = fastify;
fastify.default = fastify;
return fastify;
}

This overrides the originally exported fastify while it should contain errorCodes as assigned here. This breaks whenever I try to do this:

import { errorCodes } from 'fastify';

The errorCodes is always undefined.

Is there any workaround for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant