Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify shutdown order #59

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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 helper.getPids(pid) : [];
davecardwell marked this conversation as resolved.
Show resolved Hide resolved

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

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