@@ -47,14 +47,15 @@ class SentryCloudflareTracer implements Tracer {
4747 if ( ! topSpan ) {
4848 return sentrySpan ;
4949 }
50+ const _proxied = new WeakMap < CallableFunction , CallableFunction > ( ) ;
5051 return new Proxy ( sentrySpan , {
5152 set : ( target , p , newValue , receiver ) => {
5253 try {
53- Reflect . set ( topSpan , p , newValue , receiver ) ;
54+ Reflect . set ( topSpan , p , newValue ) ;
5455 } catch {
5556 //
5657 }
57- return Reflect . set ( target , p , newValue ) ;
58+ return Reflect . set ( target , p , newValue , receiver ) ;
5859 } ,
5960 get : ( target , p ) => {
6061 const propertyValue = Reflect . get ( target , p ) ;
@@ -65,7 +66,10 @@ class SentryCloudflareTracer implements Tracer {
6566 if ( typeof proxyTo !== 'function' ) {
6667 return propertyValue ;
6768 }
68- return new Proxy ( propertyValue , {
69+ if ( _proxied . has ( propertyValue ) ) {
70+ return _proxied . get ( propertyValue ) ;
71+ }
72+ const proxy = new Proxy ( propertyValue , {
6973 apply : ( target , thisArg , argArray ) => {
7074 try {
7175 Reflect . apply ( proxyTo , topSpan , argArray ) ;
@@ -75,6 +79,8 @@ class SentryCloudflareTracer implements Tracer {
7579 return Reflect . apply ( target , thisArg , argArray ) ;
7680 } ,
7781 } ) ;
82+ _proxied . set ( propertyValue , proxy ) ;
83+ return proxy ;
7884 } ,
7985 } ) ;
8086 }
0 commit comments