| 29 | }; |
| 30 | |
| 31 | export const injectGlobalErrorHandlers = ( |
| 32 | parentProcess: typeof Process, |
| 33 | ): Circus.GlobalErrorHandlers => { |
| 34 | const uncaughtException = [...process.listeners('uncaughtException')]; |
| 35 | const unhandledRejection = [...process.listeners('unhandledRejection')]; |
| 36 | const rejectionHandled = [...process.listeners('rejectionHandled')]; |
| 37 | parentProcess.removeAllListeners('uncaughtException'); |
| 38 | parentProcess.removeAllListeners('unhandledRejection'); |
| 39 | parentProcess.removeAllListeners('rejectionHandled'); |
| 40 | parentProcess.on('uncaughtException', uncaughtExceptionListener); |
| 41 | parentProcess.on('unhandledRejection', unhandledRejectionListener); |
| 42 | parentProcess.on('rejectionHandled', rejectionHandledListener); |
| 43 | return {rejectionHandled, uncaughtException, unhandledRejection}; |
| 44 | }; |
| 45 | |
| 46 | export const restoreGlobalErrorHandlers = ( |
| 47 | parentProcess: typeof Process, |