Skip to content

Commit

Permalink
fix: gracefullyClose unused workers
Browse files Browse the repository at this point in the history
This patch fixes issue microsoft#30504 by gracefully terminating the worker before exiting the process
  • Loading branch information
NoamGaash committed Apr 24, 2024
1 parent 230a843 commit b00e413
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/playwright/src/common/process.ts
Expand Up @@ -96,17 +96,18 @@ async function gracefullyCloseAndExit() {
if (closed)
return;
closed = true;
// Force exit after 30 seconds.
// eslint-disable-next-line no-restricted-properties
setTimeout(() => process.exit(0), 30000);
// Meanwhile, try to gracefully shutdown.
await processRunner?.gracefullyClose().catch(() => {});
if (processName)
await stopProfiling(processName).catch(() => {});
// eslint-disable-next-line no-restricted-properties
process.exit(0);
try {
// try to gracefully shutdown.
await processRunner?.gracefullyClose().catch(() => {});
if (processName)
await stopProfiling(processName).catch(() => {});
} finally {
// eslint-disable-next-line no-restricted-properties
process.exit(0);
}
}


function sendMessageToParent(message: { method: string, params?: any }) {
try {
process.send!(message);
Expand Down

0 comments on commit b00e413

Please sign in to comment.