()
| 367 | // a warning to be emitted which requires the microtask and next tick |
| 368 | // queues to be drained again. |
| 369 | function processPromiseRejections() { |
| 370 | let maybeScheduledTicksOrMicrotasks = !asyncHandledRejections.isEmpty(); |
| 371 | |
| 372 | while (!asyncHandledRejections.isEmpty()) { |
| 373 | const { promise, warning } = asyncHandledRejections.shift(); |
| 374 | if (!process.emit('rejectionHandled', promise)) { |
| 375 | process.emitWarning(warning); |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | let needPop = true; |
| 380 | let promiseAsyncId; |
| 381 | |
| 382 | const pending = pendingUnhandledRejections; |
| 383 | pendingUnhandledRejections = new SafeMap(); |
| 384 | |
| 385 | for (const { 0: promise, 1: promiseInfo } of pending.entries()) { |
| 386 | maybeUnhandledPromises.set(promise, promiseInfo); |
| 387 | |
| 388 | promiseInfo.warned = true; |
| 389 | |
| 390 | // We need to check if async_hooks are enabled |
| 391 | // don't use enabledHooksExist as a Promise could |
| 392 | // come from a vm.* context and not have an async id |
| 393 | promiseAsyncId = promise[kAsyncIdSymbol]; |
| 394 | if (promiseAsyncId !== undefined) { |
| 395 | pushAsyncContext( |
| 396 | promiseAsyncId, |
| 397 | promise[kTriggerAsyncIdSymbol], |
| 398 | promise, |
| 399 | ); |
| 400 | } |
| 401 | |
| 402 | const { contextFrame } = promiseInfo; |
| 403 | const priorContextFrame = AsyncContextFrame.exchange(contextFrame); |
| 404 | try { |
| 405 | needPop = unhandledRejectionsMode(promise, promiseInfo, promiseAsyncId); |
| 406 | } finally { |
| 407 | AsyncContextFrame.set(priorContextFrame); |
| 408 | needPop && |
| 409 | promiseAsyncId !== undefined && |
| 410 | popAsyncContext(promiseAsyncId); |
| 411 | } |
| 412 | maybeScheduledTicksOrMicrotasks = true; |
| 413 | } |
| 414 | return maybeScheduledTicksOrMicrotasks || |
| 415 | pendingUnhandledRejections.size !== 0; |
| 416 | } |
| 417 | |
| 418 | function listenForRejections() { |
| 419 | setPromiseRejectCallback(promiseRejectHandler); |
no test coverage detected
searching dependent graphs…