Skip to content

Commit e1ac1e9

Browse files
committed
bugfix(node): Fix an issue where applying patches fails in CJS
1 parent 08dc233 commit e1ac1e9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/node/src/integrations/tracing/hono/instrumentation.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class HonoInstrumentation extends InstrumentationBase {
4141
// eslint-disable-next-line @typescript-eslint/no-this-alias
4242
const instrumentation = this;
4343

44-
moduleExports.Hono = class HonoWrapper extends moduleExports.Hono {
44+
class WrappedHono extends moduleExports.Hono {
4545
public constructor(...args: unknown[]) {
4646
super(...args);
4747

@@ -55,7 +55,15 @@ export class HonoInstrumentation extends InstrumentationBase {
5555
instrumentation._wrap(this, 'on', instrumentation._patchOnHandler());
5656
instrumentation._wrap(this, 'use', instrumentation._patchMiddlewareHandler());
5757
}
58-
};
58+
}
59+
60+
try {
61+
moduleExports.Hono = WrappedHono;
62+
} catch {
63+
// This is a workaround for environments where direct assignment is not allowed.
64+
return { ...moduleExports, Hono: WrappedHono };
65+
}
66+
5967
return moduleExports;
6068
}
6169

0 commit comments

Comments
 (0)