Fix processExit

Summary: setTimeout should terminate process if graceful termination takes too long. Before, we scheduled the timer only *after* the graceful termination completes which does not make any sense

Reviewed By: lblasa

Differential Revision: D51346673

fbshipit-source-id: b5adadbcf474a8c66839e1fc70bcc6482c47635e
This commit is contained in:
Andrey Goncharov
2023-11-15 03:46:46 -08:00
committed by Facebook GitHub Bot
parent 6ccae92918
commit ed7a7f7bd0

View File

@@ -19,6 +19,11 @@ const resIsPromise = (res: void | Promise<void>): res is Promise<void> =>
export const processExit = async (code: number) => {
console.debug('processExit', code);
setTimeout(() => {
console.error('Process exit routines timed out');
process.exit(code);
}, 5000);
// eslint-disable-next-line promise/catch-or-return
await Promise.all(
onBeforeExitFns.map(async (fn) => {
@@ -36,9 +41,4 @@ export const processExit = async (code: number) => {
).finally(() => {
process.exit(code);
});
setTimeout(() => {
console.error('Process exit routines timed out');
process.exit(code);
}, 5000);
};