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
Copy file name to clipboardExpand all lines: packages/node-integration-tests/suites/public-api/OnUncaughtException/mimic-native-behaviour-additional-listener-test-script.js
Copy file name to clipboardExpand all lines: packages/node-integration-tests/suites/public-api/OnUncaughtException/mimic-native-behaviour-no-additional-listener-test-script.js
// we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down
141
-
__DEBUG_BUILD__&&
142
-
logger.warn('uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown');
143
-
logAndExitProcess(error);
144
-
}elseif(!caughtSecondError&&shouldExitProcess){
145
-
// two cases for how we can hit this branch:
146
-
// - capturing of first error blew up and we just caught the exception from that
147
-
// - quit trying to capture, proceed with shutdown
148
-
// - a second independent error happened while waiting for first error to capture
149
-
// - want to avoid causing premature shutdown before first error capture finishes
150
-
// it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
151
-
// so let's instead just delay a bit before we proceed with our action here
152
-
// in case 1, we just wait a bit unnecessarily but ultimately do the same thing
153
-
// in case 2, the delay hopefully made us wait long enough for the capture to finish
154
-
// two potential nonideal outcomes:
155
-
// nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
156
-
// 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
157
-
// note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
158
-
// we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
159
-
caughtSecondError=true;
160
-
setTimeout(()=>{
161
-
if(!calledFatalError){
162
-
// it was probably case 1, let's treat err as the sendErr and call onFatalError
163
-
calledFatalError=true;
164
-
onFatalError(firstError,error);
165
-
}else{
166
-
// it was probably case 2, our first error finished capturing while we waited, cool, do nothing
141
+
}else{
142
+
if(shouldApplyFatalHandlingLogic){
143
+
if(calledFatalError){
144
+
// we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down
145
+
__DEBUG_BUILD__&&
146
+
logger.warn(
147
+
'uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown',
148
+
);
149
+
logAndExitProcess(error);
150
+
}elseif(!caughtSecondError){
151
+
// two cases for how we can hit this branch:
152
+
// - capturing of first error blew up and we just caught the exception from that
153
+
// - quit trying to capture, proceed with shutdown
154
+
// - a second independent error happened while waiting for first error to capture
155
+
// - want to avoid causing premature shutdown before first error capture finishes
156
+
// it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
157
+
// so let's instead just delay a bit before we proceed with our action here
158
+
// in case 1, we just wait a bit unnecessarily but ultimately do the same thing
159
+
// in case 2, the delay hopefully made us wait long enough for the capture to finish
160
+
// two potential nonideal outcomes:
161
+
// nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
162
+
// 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
163
+
// note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
164
+
// we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
165
+
caughtSecondError=true;
166
+
setTimeout(()=>{
167
+
if(!calledFatalError){
168
+
// it was probably case 1, let's treat err as the sendErr and call onFatalError
169
+
calledFatalError=true;
170
+
onFatalError(firstError,error);
171
+
}else{
172
+
// it was probably case 2, our first error finished capturing while we waited, cool, do nothing
173
+
}
174
+
},timeout);// capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc
167
175
}
168
-
},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