refactor(baoyu-danger-x-to-markdown): use graceful Chrome shutdown
This commit is contained in:
parent
0ee6dd4305
commit
5eeb1e6d8d
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
|
"configVersion": 0,
|
||||||
"workspaces": {
|
"workspaces": {
|
||||||
"": {
|
"": {
|
||||||
"name": "baoyu-danger-x-to-markdown-scripts",
|
"name": "baoyu-danger-x-to-markdown-scripts",
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ import {
|
||||||
CdpConnection,
|
CdpConnection,
|
||||||
findChromeExecutable as findChromeExecutableBase,
|
findChromeExecutable as findChromeExecutableBase,
|
||||||
findExistingChromeDebugPort,
|
findExistingChromeDebugPort,
|
||||||
|
gracefulKillChrome,
|
||||||
getFreePort,
|
getFreePort,
|
||||||
killChrome,
|
|
||||||
launchChrome as launchChromeBase,
|
launchChrome as launchChromeBase,
|
||||||
openPageSession,
|
openPageSession,
|
||||||
sleep,
|
sleep,
|
||||||
|
|
@ -122,15 +122,11 @@ async function fetchXCookiesViaCdp(
|
||||||
try {
|
try {
|
||||||
await cdp.send("Target.closeTarget", { targetId }, { timeoutMs: 5_000 });
|
await cdp.send("Target.closeTarget", { targetId }, { timeoutMs: 5_000 });
|
||||||
} catch {}
|
} catch {}
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
await cdp.send("Browser.close", {}, { timeoutMs: 5_000 });
|
|
||||||
} catch {}
|
|
||||||
}
|
}
|
||||||
cdp.close();
|
cdp.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chrome) killChrome(chrome);
|
if (chrome) await gracefulKillChrome(chrome, port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue