@@ -47,14 +47,15 @@ class SentryCloudflareTracer implements Tracer {
47
47
if ( ! topSpan ) {
48
48
return sentrySpan ;
49
49
}
50
+ const _proxied = new WeakMap < CallableFunction , CallableFunction > ( ) ;
50
51
return new Proxy ( sentrySpan , {
51
52
set : ( target , p , newValue , receiver ) => {
52
53
try {
53
- Reflect . set ( topSpan , p , newValue , receiver ) ;
54
+ Reflect . set ( topSpan , p , newValue ) ;
54
55
} catch {
55
56
//
56
57
}
57
- return Reflect . set ( target , p , newValue ) ;
58
+ return Reflect . set ( target , p , newValue , receiver ) ;
58
59
} ,
59
60
get : ( target , p ) => {
60
61
const propertyValue = Reflect . get ( target , p ) ;
@@ -65,7 +66,10 @@ class SentryCloudflareTracer implements Tracer {
65
66
if ( typeof proxyTo !== 'function' ) {
66
67
return propertyValue ;
67
68
}
68
- return new Proxy ( propertyValue , {
69
+ if ( _proxied . has ( propertyValue ) ) {
70
+ return _proxied . get ( propertyValue ) ;
71
+ }
72
+ const proxy = new Proxy ( propertyValue , {
69
73
apply : ( target , thisArg , argArray ) => {
70
74
try {
71
75
Reflect . apply ( proxyTo , topSpan , argArray ) ;
@@ -75,6 +79,8 @@ class SentryCloudflareTracer implements Tracer {
75
79
return Reflect . apply ( target , thisArg , argArray ) ;
76
80
} ,
77
81
} ) ;
82
+ _proxied . set ( propertyValue , proxy ) ;
83
+ return proxy ;
78
84
} ,
79
85
} ) ;
80
86
}
0 commit comments