Skip to content

Commit 4449737

Browse files
committed
Properly await termination.
1 parent 6709c3b commit 4449737

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

server.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,12 @@ function createHttpsServer(keys) {
535535

536536
// Graceful shutdown when signalled
537537
const terminator = createHttpTerminator({server: listener});
538-
process.on('SIGINT', ()=> {
539-
console.debug('Closing HTTPS server on signal');
540-
terminator.terminate().catch(e => { console.error(e); });
541-
console.debug('HTTPS server closed');
538+
process.on('SIGINT', () => {
539+
void (async ()=> {
540+
console.debug('Closing HTTPS server on signal');
541+
await terminator.terminate().catch(e => { console.error(e); });
542+
console.debug('HTTPS server closed');
543+
})();
542544
});
543545
}
544546

@@ -554,10 +556,12 @@ function run() {
554556

555557
// Graceful shutdown when signalled
556558
const terminator = createHttpTerminator({server: listener});
557-
process.on('SIGINT', ()=> {
558-
console.debug('Closing HTTP server on signal');
559-
terminator.terminate().catch(e => { console.error(e); });
560-
console.debug('HTTP server closed.');
559+
process.on('SIGINT', () => {
560+
void (async () => {
561+
console.debug('Closing HTTP server on signal');
562+
await terminator.terminate().catch(e => { console.error(e); });
563+
console.debug('HTTP server closed.');return undefined;
564+
})();
561565
});
562566
}
563567

0 commit comments

Comments
 (0)