You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// consoleSandbox reads originalConsoleMethods[level] to temporarily bypass instrumentation. We replace it with a distinct reference (.bind creates a
83
+
// new function identity) so the setter can tell apart "consoleSandbox bypass" from "external code restoring a native method captured before Sentry init."
84
+
constsandboxBypass=nativeMethod.bind(consoleObj);
85
+
originalConsoleMethods[level]=sandboxBypass;
86
+
83
87
try{
84
88
letcurrent: any=wrapper;
85
89
86
-
Object.defineProperty(GLOBAL_OBJ.console,level,{
90
+
Object.defineProperty(consoleObj,level,{
87
91
configurable: true,
88
92
enumerable: true,
89
93
get(){
90
94
returncurrent;
91
95
},
92
96
set(newValue){
93
-
if(
94
-
typeofnewValue==='function'&&
95
-
newValue!==wrapper&&
96
-
newValue!==originalConsoleMethods[level]&&
97
-
!(newValueasWrappedFunction).__sentry_original__
98
-
){
99
-
consoleDelegate=newValue;
97
+
if(newValue===wrapper){
98
+
// consoleSandbox restoring the wrapper: recover the saved delegate.
99
+
if(savedDelegate!==undefined){
100
+
delegate=savedDelegate;
101
+
savedDelegate=undefined;
102
+
}
103
+
current=wrapper;
104
+
}elseif(newValue===sandboxBypass){
105
+
// consoleSandbox entering bypass: save delegate, let getter return sandboxBypass directly so calls skip the wrapper entirely.
0 commit comments