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
// we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down
92
+
logger.warn('uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown');
93
+
defaultOnFatalError(error);
94
+
}elseif(!caughtSecondError){
95
+
// two cases for how we can hit this branch:
96
+
// - capturing of first error blew up and we just caught the exception from that
97
+
// - quit trying to capture, proceed with shutdown
98
+
// - a second independent error happened while waiting for first error to capture
99
+
// - want to avoid causing premature shutdown before first error capture finishes
100
+
// it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
101
+
// so let's instead just delay a bit before we proceed with our action here
102
+
// in case 1, we just wait a bit unnecessarily but ultimately do the same thing
103
+
// in case 2, the delay hopefully made us wait long enough for the capture to finish
104
+
// two potential nonideal outcomes:
105
+
// nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
106
+
// nonideal case 2: case 2 happens, 1st error is captured but slowly, timeout completes before capture and we treat second error as the sendErr of (nonexistent) failure from trying to capture first error
107
+
// note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
108
+
// we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
109
+
caughtSecondError=true;
110
+
setTimeout(()=>{
111
+
if(!calledFatalError){
112
+
// it was probably case 1, let's treat err as the sendErr and call onFatalError
113
+
calledFatalError=true;
114
+
onFatalError(firstError,error);
115
+
}else{
116
+
// it was probably case 2, our first error finished capturing while we waited, cool, do nothing
117
+
}
118
+
},timeout);// capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc
82
119
}
83
-
}elseif(calledFatalError){
84
-
// we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down
85
-
logger.warn('uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown');
86
-
defaultOnFatalError(error);
87
-
}elseif(!caughtSecondError){
88
-
// two cases for how we can hit this branch:
89
-
// - capturing of first error blew up and we just caught the exception from that
90
-
// - quit trying to capture, proceed with shutdown
91
-
// - a second independent error happened while waiting for first error to capture
92
-
// - want to avoid causing premature shutdown before first error capture finishes
93
-
// it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
94
-
// so let's instead just delay a bit before we proceed with our action here
95
-
// in case 1, we just wait a bit unnecessarily but ultimately do the same thing
96
-
// in case 2, the delay hopefully made us wait long enough for the capture to finish
97
-
// two potential nonideal outcomes:
98
-
// nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
99
-
// nonideal case 2: case 2 happens, 1st error is captured but slowly, timeout completes before capture and we treat second error as the sendErr of (nonexistent) failure from trying to capture first error
100
-
// note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
101
-
// we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
102
-
caughtSecondError=true;
103
-
setTimeout(()=>{
104
-
if(!calledFatalError){
105
-
// it was probably case 1, let's treat err as the sendErr and call onFatalError
106
-
calledFatalError=true;
107
-
onFatalError(firstError,error);
108
-
}else{
109
-
// it was probably case 2, our first error finished capturing while we waited, cool, do nothing
110
-
}
111
-
},timeout);// capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc
0 commit comments