(error, fromPromise)
| 240 | }); |
| 241 | |
| 242 | function 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(). |
no test coverage detected
searching dependent graphs…