let unhandledRejectionCount = 0 ; process . on ( "unhandledRejection" , ( reason ) : void => { console . log ( "unhandled rejection:" , reason ) ; unhandledRejectionCount ++ ; throw reason ; } ) ; process . prependListener ( "exit" , ( code ) : void => { if ( code === 0 && unhandledRejectionCount !== 0 ) { process . exit ( 1 ) ; } } ) ;