Skip to content
This repository has been archived by the owner on Mar 3, 2025. It is now read-only.

Modify shutdown order #59

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 10 additions & 25 deletions src/core/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,32 +276,17 @@ export default class Driver {
* @param browser
*/
static async shutdown(browser: Browser) {
try {
const pages = await browser.pages()
for (const page of pages) {
await page.close()
}
} catch (ignored) {
}

const browserProcess = browser.process()
if (browserProcess) {
const pid = browserProcess.pid

if (pid) {
const pids = await this.getPids(pid)
pids.forEach(pid => {
try {
process.kill(pid, 'SIGKILL')
} catch (ignored) {
}
})
}
}
const pid = browser.process()?.pid;
const pids = pid ? await this.getPids(pid) : [];

try {
await browser.close()
} catch (ignored) {
}
await browser.close();
} catch (ignored) {}

pids.forEach((pid) => {
try {
process.kill(pid, 'SIGKILL');
} catch (ignored) {}
});
}
}