MCPcopy Index your code
hub / github.com/nodejs/node / workerOnGlobalUncaughtException

Function workerOnGlobalUncaughtException

lib/internal/main/worker_thread.js:242–290  ·  view source on GitHub ↗
(error, fromPromise)

Source from the content-addressed store, hash-verified

240});
241
242function workerOnGlobalUncaughtException(error, fromPromise) {
243 debug(`[${threadId}] gets uncaught exception`);
244 let handled = false;
245 let handlerThrew = false;
246 try {
247 handled = onGlobalUncaughtException(error, fromPromise);
248 } catch (e) {
249 error = e;
250 handlerThrew = true;
251 }
252 debug(`[${threadId}] uncaught exception handled = ${handled}`);
253
254 if (handled) {
255 return true;
256 }
257
258 if (!process._exiting) {
259 try {
260 process._exiting = true;
261 process.exitCode = kGenericUserError;
262 if (!handlerThrew) {
263 process.emit('exit', process.exitCode);
264 }
265 } catch {
266 // Continue regardless of error.
267 }
268 }
269
270 let serialized;
271 try {
272 const { serializeError } = require('internal/error_serdes');
273 serialized = serializeError(error);
274 } catch {
275 // Continue regardless of error.
276 }
277 debug(`[${threadId}] uncaught exception serialized = ${!!serialized}`);
278 if (serialized)
279 port.postMessage({
280 type: ERROR_MESSAGE,
281 error: serialized,
282 });
283 else
284 port.postMessage({ type: COULD_NOT_SERIALIZE_ERROR });
285
286 const { clearAsyncIdStack } = require('internal/async_hooks');
287 clearAsyncIdStack();
288
289 process.exit();
290}
291
292// Patch the global uncaught exception handler so it gets picked up by
293// node::errors::TriggerUncaughtException().

Callers 1

worker_thread.jsFile · 0.85

Calls 6

debugFunction · 0.50
requireFunction · 0.50
serializeErrorFunction · 0.50
emitMethod · 0.45
postMessageMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…