MCPcopy
hub / github.com/microsoft/playwright / gracefullyClose

Function gracefullyClose

packages/utils/processLauncher.ts:207–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

205
206 let gracefullyClosing = false;
207 async function gracefullyClose(): Promise<void> {
208 // We keep listeners until we are done, to handle 'exit' and 'SIGINT' while
209 // asynchronously closing to prevent zombie processes. This might introduce
210 // reentrancy to this function, for example user sends SIGINT second time.
211 // In this case, let's forcefully kill the process.
212 if (gracefullyClosing) {
213 options.log(`[pid=${spawnedProcess.pid}] <forcefully close>`);
214 killProcess();
215 await waitForCleanup; // Ensure the process is dead and we have cleaned up.
216 return;
217 }
218 gracefullyClosing = true;
219 options.log(`[pid=${spawnedProcess.pid}] <gracefully close start>`);
220 await options.attemptToGracefullyClose().catch(() => killProcess());
221 await waitForCleanup; // Ensure the process is dead and we have cleaned up.
222 options.log(`[pid=${spawnedProcess.pid}] <gracefully close end>`);
223 }
224
225 // This method has to be sync to be used in the 'exit' event handler.
226 function killProcess() {

Callers 2

gracefullyCloseAllFunction · 0.85
closeOrKillFunction · 0.85

Calls 3

killProcessFunction · 0.85
catchMethod · 0.80
logMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…