Skip to content

Commit 79a7421

Browse files
committed
fixup! fix(cloudflare): Make sure enableRpcTracePropagation is ranked higher
1 parent 2d80f42 commit 79a7421

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

packages/cloudflare/src/durableobject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export function instrumentDurableObjectWithSentry<
145145
get(proxyTarget, prop, receiver) {
146146
const value = Reflect.get(proxyTarget, prop, receiver);
147147

148-
if (typeof prop !== 'string' || typeof value !== 'function') {
148+
if (typeof prop !== 'string' || typeof value !== 'function' || prop === 'constructor') {
149149
return value;
150150
}
151151

packages/cloudflare/test/durableobject.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ describe('instrumentDurableObjectWithSentry', () => {
216216
expect(obj.rpcMethod()).toBe('rpc');
217217
});
218218

219+
it('preserves constructor identity on the proxy', () => {
220+
const testClass = class MyDO {
221+
rpcMethod() {
222+
return 'result';
223+
}
224+
};
225+
const instrumented = instrumentDurableObjectWithSentry(
226+
vi.fn().mockReturnValue({ enableRpcTracePropagation: true }),
227+
testClass as any,
228+
);
229+
const obj = Reflect.construct(instrumented, []);
230+
231+
// constructor must remain the original class reference for identity/type checks
232+
expect(obj.constructor).toBe(testClass);
233+
});
234+
219235
it('Does not instrument RPC methods when instrumentPrototypeMethods is not set', () => {
220236
const testClass = class {
221237
rpcMethod() {

0 commit comments

Comments
 (0)