@@ -56,6 +56,14 @@ const ERRORS = {
5656 ABORT : "abort" ,
5757} ;
5858
59+ const PROCESS_EVENTS = {
60+ EXIT : "exit" ,
61+ BEFORE_EXIT : "beforeExit" ,
62+ DISCONNECT : "disconnect" ,
63+ MESSAGE : "message" ,
64+ WORKER_MESSAGE : "workerMessage" ,
65+ } ;
66+
5967const EVENTS = {
6068 DATA : "data" ,
6169 ERROR : "error" ,
@@ -94,9 +102,11 @@ function updateEnv() {
94102}
95103
96104const globalExceptionsAndErrors : any = { } ;
105+ const globalProcessListeners : any [ ] = [ ] ;
97106function onGlobalError ( error : any ) {
98107 process . on ( error , function ( err ) {
99108 pushGlobalError ( error , err ) ;
109+ globalProcessListeners . forEach ( ( cb ) => cb ( error , err ) ) ;
100110 } ) ;
101111}
102112function pushGlobalError ( error : any , err : any ) {
@@ -109,12 +119,18 @@ function uncaughtExceptionGlobal() {
109119 ( global as zetaret . node . BasicServerGlobal ) . onGlobalError = onGlobalError ;
110120 ( global as zetaret . node . BasicServerGlobal ) . pushGlobalError = pushGlobalError ;
111121 ( global as zetaret . node . BasicServerGlobal ) . globalExceptionsAndErrors = globalExceptionsAndErrors ;
122+ ( global as zetaret . node . BasicServerGlobal ) . globalProcessListeners = globalProcessListeners ;
112123 } else return ;
113124 onGlobalError ( ERRORS . UNCAUGHT_EXCEPTION ) ;
114125 onGlobalError ( ERRORS . UNCAUGHT_EXCEPTION_MONITOR ) ;
115126 onGlobalError ( ERRORS . UNHANDLED_REJECTION ) ;
116127 onGlobalError ( ERRORS . UNHANDLED_PROMISE_REJECTION_WARNING ) ;
117128 onGlobalError ( ERRORS . WARNING ) ;
129+ onGlobalError ( PROCESS_EVENTS . EXIT ) ;
130+ onGlobalError ( PROCESS_EVENTS . BEFORE_EXIT ) ;
131+ onGlobalError ( PROCESS_EVENTS . DISCONNECT ) ;
132+ onGlobalError ( PROCESS_EVENTS . MESSAGE ) ;
133+ onGlobalError ( PROCESS_EVENTS . WORKER_MESSAGE ) ;
118134}
119135
120136function resetFSInterval ( ) {
0 commit comments