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
98
-
__DEBUG_BUILD__&&
99
-
logger.warn('uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown');
100
-
logAndExitProcess(error);
101
-
}elseif(!caughtSecondError){
102
-
// two cases for how we can hit this branch:
103
-
// - capturing of first error blew up and we just caught the exception from that
104
-
// - quit trying to capture, proceed with shutdown
105
-
// - a second independent error happened while waiting for first error to capture
106
-
// - want to avoid causing premature shutdown before first error capture finishes
107
-
// it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
108
-
// so let's instead just delay a bit before we proceed with our action here
109
-
// in case 1, we just wait a bit unnecessarily but ultimately do the same thing
110
-
// in case 2, the delay hopefully made us wait long enough for the capture to finish
111
-
// two potential nonideal outcomes:
112
-
// nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
113
-
// 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
114
-
// note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
115
-
// we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
116
-
caughtSecondError=true;
117
-
setTimeout(()=>{
118
-
if(!calledFatalError){
119
-
// it was probably case 1, let's treat err as the sendErr and call onFatalError
120
-
calledFatalError=true;
121
-
onFatalError(firstError,error);
122
-
}else{
123
-
// it was probably case 2, our first error finished capturing while we waited, cool, do nothing
140
+
}else{
141
+
if(shouldApplyFatalHandlingLogic){
142
+
if(calledFatalError){
143
+
// we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down
144
+
__DEBUG_BUILD__&&
145
+
logger.warn(
146
+
'uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown',
147
+
);
148
+
logAndExitProcess(error);
149
+
}elseif(!caughtSecondError){
150
+
// two cases for how we can hit this branch:
151
+
// - capturing of first error blew up and we just caught the exception from that
152
+
// - quit trying to capture, proceed with shutdown
153
+
// - a second independent error happened while waiting for first error to capture
154
+
// - want to avoid causing premature shutdown before first error capture finishes
155
+
// it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
156
+
// so let's instead just delay a bit before we proceed with our action here
157
+
// in case 1, we just wait a bit unnecessarily but ultimately do the same thing
158
+
// in case 2, the delay hopefully made us wait long enough for the capture to finish
159
+
// two potential nonideal outcomes:
160
+
// nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
161
+
// 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
162
+
// note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
163
+
// we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
164
+
caughtSecondError=true;
165
+
setTimeout(()=>{
166
+
if(!calledFatalError){
167
+
// it was probably case 1, let's treat err as the sendErr and call onFatalError
168
+
calledFatalError=true;
169
+
onFatalError(firstError,error);
170
+
}else{
171
+
// it was probably case 2, our first error finished capturing while we waited, cool, do nothing
172
+
}
173
+
},timeout);// capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc
124
174
}
125
-
},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