File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
packages/core/src/integrations Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,16 @@ export class FunctionToString implements Integration {
22
22
// eslint-disable-next-line @typescript-eslint/unbound-method
23
23
originalFunctionToString = Function . prototype . toString ;
24
24
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- Function . prototype . toString = function ( this : WrappedFunction , ...args : any [ ] ) : string {
27
- const context = getOriginalFunction ( this ) || this ;
28
- return originalFunctionToString . apply ( context , args ) ;
29
- } ;
25
+ // intrinsics (like Function.prototype) might be immutable in some environments
26
+ // e.g. Node with --frozen-intrinsics, XS (an embedded JavaScript engine) or SES (a JavaScript proposal)
27
+ try {
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ Function . prototype . toString = function ( this : WrappedFunction , ...args : any [ ] ) : string {
30
+ const context = getOriginalFunction ( this ) || this ;
31
+ return originalFunctionToString . apply ( context , args ) ;
32
+ } ;
33
+ } catch {
34
+ // ignore errors here, just don't patch this
35
+ }
30
36
}
31
37
}
You can’t perform that action at this time.
0 commit comments