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