fix: gracefullyClose unused workers

This patch fixes issue #30504 by gracefully terminating the worker before exiting the process
This commit is contained in:
Noam Gaash 2024-04-24 16:28:38 +03:00
parent 230a8437d3
commit b00e413cb0

View file

@ -96,17 +96,18 @@ async function gracefullyCloseAndExit() {
if (closed) if (closed)
return; return;
closed = true; closed = true;
// Force exit after 30 seconds. try {
// eslint-disable-next-line no-restricted-properties // try to gracefully shutdown.
setTimeout(() => process.exit(0), 30000); await processRunner?.gracefullyClose().catch(() => {});
// Meanwhile, try to gracefully shutdown. if (processName)
await processRunner?.gracefullyClose().catch(() => {}); await stopProfiling(processName).catch(() => {});
if (processName) } finally {
await stopProfiling(processName).catch(() => {}); // eslint-disable-next-line no-restricted-properties
// eslint-disable-next-line no-restricted-properties process.exit(0);
process.exit(0); }
} }
function sendMessageToParent(message: { method: string, params?: any }) { function sendMessageToParent(message: { method: string, params?: any }) {
try { try {
process.send!(message); process.send!(message);