File tree 3 files changed +26
-1
lines changed
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
6
6
7
+ ## 7.119.1
8
+
9
+ - fix(browser/v7): Ensure wrap() only returns functions (#13838 backport)
10
+
11
+ Work in this release contributed by @legobeat . Thank you for your contribution!
12
+
7
13
## 7.119.0
8
14
9
15
- backport(tracing): Report dropped spans for transactions (#13343 )
Original file line number Diff line number Diff line change @@ -66,7 +66,13 @@ export function wrap(
66
66
// the original wrapper.
67
67
const wrapper = fn . __sentry_wrapped__ ;
68
68
if ( wrapper ) {
69
- return wrapper ;
69
+ if ( typeof wrapper === 'function' ) {
70
+ return wrapper ;
71
+ } else {
72
+ // If we find that the `__sentry_wrapped__` function is not a function at the time of accessing it, it means
73
+ // that something messed with it. In that case we want to return the originally passed function.
74
+ return fn ;
75
+ }
70
76
}
71
77
72
78
// We don't wanna wrap it twice
Original file line number Diff line number Diff line change @@ -174,4 +174,17 @@ describe('internal wrap()', () => {
174
174
expect ( wrapped . __sentry_original__ ) . toBe ( fn ) ;
175
175
expect ( fn . __sentry_wrapped__ ) . toBe ( wrapped ) ;
176
176
} ) ;
177
+
178
+ it ( 'should only return __sentry_wrapped__ when it is a function' , ( ) => {
179
+ const fn = ( ( ) => 1337 ) as WrappedFunction ;
180
+
181
+ wrap ( fn ) ;
182
+ expect ( fn ) . toHaveProperty ( '__sentry_wrapped__' ) ;
183
+ fn . __sentry_wrapped__ = 'something that is not a function' as any ;
184
+
185
+ const wrapped = wrap ( fn ) ;
186
+
187
+ expect ( wrapped ) . toBe ( fn ) ;
188
+ expect ( wrapped ) . not . toBe ( 'something that is not a function' ) ;
189
+ } ) ;
177
190
} ) ;
You can’t perform that action at this time.
0 commit comments