File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 11import { reportError } from './error-tracking' ;
2+ import { delay } from './util' ;
23
34type ShutdownHandler = ( ) => Promise < unknown > ;
45const shutdownHandlers : Array < ShutdownHandler > = [ ] ;
@@ -15,16 +16,21 @@ export function addShutdownHandler(handler: ShutdownHandler) {
1516async function shutdown ( ) {
1617 console . log ( 'Shutting down...' ) ;
1718
18- await Promise . all ( shutdownHandlers . map (
19+ const shutdownPromises = Promise . all ( shutdownHandlers . map (
1920 async ( handler ) => {
2021 try {
21- handler ( ) ;
22+ await handler ( ) ;
2223 } catch ( e ) {
2324 reportError ( e ) ;
2425 }
2526 }
2627 ) ) ;
2728
29+ await Promise . race ( [
30+ shutdownPromises ,
31+ delay ( 2000 ) // After 2 seconds, we just close anyway, we're done.
32+ ] ) ;
33+
2834 process . exit ( 0 ) ;
2935}
3036
You can’t perform that action at this time.
0 commit comments