| 44 | }; |
| 45 | |
| 46 | export const restoreGlobalErrorHandlers = ( |
| 47 | parentProcess: typeof Process, |
| 48 | originalErrorHandlers: Circus.GlobalErrorHandlers, |
| 49 | ): void => { |
| 50 | parentProcess.removeListener('uncaughtException', uncaughtExceptionListener); |
| 51 | parentProcess.removeListener( |
| 52 | 'unhandledRejection', |
| 53 | unhandledRejectionListener, |
| 54 | ); |
| 55 | parentProcess.removeListener('rejectionHandled', rejectionHandledListener); |
| 56 | |
| 57 | for (const listener of originalErrorHandlers.uncaughtException) { |
| 58 | parentProcess.on('uncaughtException', listener); |
| 59 | } |
| 60 | for (const listener of originalErrorHandlers.unhandledRejection) { |
| 61 | parentProcess.on('unhandledRejection', listener); |
| 62 | } |
| 63 | for (const listener of originalErrorHandlers.rejectionHandled) { |
| 64 | parentProcess.on('rejectionHandled', listener); |
| 65 | } |
| 66 | }; |