11
This commit is contained in:
@@ -73,7 +73,11 @@ class DouyinBrowserManager {
|
||||
constructor() {
|
||||
this.browser = null;
|
||||
this.isInitializing = false;
|
||||
this.userDataPath = getRuntimeDataPath("browser-data", "douyin");
|
||||
// 下载链路使用独立临时 profile,避免与其他流程/遗留进程抢占同一目录锁。
|
||||
this.userDataPath = getRuntimeDataPath(
|
||||
"temp",
|
||||
`douyin-pipeline-${process.pid}-${Date.now()}`
|
||||
);
|
||||
}
|
||||
|
||||
static getInstance() {
|
||||
@@ -180,8 +184,10 @@ class DouyinBrowserManager {
|
||||
const page = await this.browser.newPage();
|
||||
await page.setUserAgent(DEFAULT_USER_AGENT);
|
||||
await page.evaluateOnNewDocument(STEALTH_INIT_SCRIPT);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
page.setDefaultTimeout(60000);
|
||||
const pageTimeoutMs =
|
||||
Number(process.env.AICLIENT_DOUYIN_PAGE_TIMEOUT_MS) || 90_000;
|
||||
page.setDefaultNavigationTimeout(pageTimeoutMs);
|
||||
page.setDefaultTimeout(pageTimeoutMs);
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -192,6 +198,16 @@ class DouyinBrowserManager {
|
||||
this.browser = null;
|
||||
console.log("浏览器管理器已关闭");
|
||||
}
|
||||
if (
|
||||
this.userDataPath &&
|
||||
this.userDataPath.includes(`${path.sep}temp${path.sep}douyin-pipeline-`)
|
||||
) {
|
||||
try {
|
||||
fs.rmSync(this.userDataPath, { recursive: true, force: true });
|
||||
} catch {
|
||||
/* ignore temp dir cleanup errors */
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("关闭浏览器管理器失败:", error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user