Upload screenshotService.js
Browse files
backend/src/services/screenshotService.js
CHANGED
|
@@ -141,7 +141,7 @@ class ScreenshotService {
|
|
| 141 |
handleSIGTERM: false,
|
| 142 |
handleSIGHUP: false,
|
| 143 |
dumpio: false, // 禁用浏览器日志输出到控制台
|
| 144 |
-
protocolTimeout:
|
| 145 |
};
|
| 146 |
|
| 147 |
// 检测环境并应用特定优化
|
|
@@ -551,7 +551,7 @@ class ScreenshotService {
|
|
| 551 |
quality = 90,
|
| 552 |
width = 1000,
|
| 553 |
height = 562,
|
| 554 |
-
timeout =
|
| 555 |
} = options;
|
| 556 |
|
| 557 |
// 检查缓存
|
|
@@ -679,10 +679,10 @@ class ScreenshotService {
|
|
| 679 |
// 设置视口大小(即使从池中获取的页面也需要重新设置,因为尺寸可能不同)
|
| 680 |
await page.setViewport({ width, height });
|
| 681 |
|
| 682 |
-
//
|
| 683 |
await page.setContent(htmlContent, {
|
| 684 |
waitUntil: 'networkidle0',
|
| 685 |
-
timeout: Math.min(timeout,
|
| 686 |
});
|
| 687 |
|
| 688 |
// 等待字体加载
|
|
|
|
| 141 |
handleSIGTERM: false,
|
| 142 |
handleSIGHUP: false,
|
| 143 |
dumpio: false, // 禁用浏览器日志输出到控制台
|
| 144 |
+
protocolTimeout: 30000 // 增加协议超时时间,解决Network.enable超时问题
|
| 145 |
};
|
| 146 |
|
| 147 |
// 检测环境并应用特定优化
|
|
|
|
| 551 |
quality = 90,
|
| 552 |
width = 1000,
|
| 553 |
height = 562,
|
| 554 |
+
timeout = 30000 // 增加默认超时时间,与protocolTimeout保持一致
|
| 555 |
} = options;
|
| 556 |
|
| 557 |
// 检查缓存
|
|
|
|
| 679 |
// 设置视口大小(即使从池中获取的页面也需要重新设置,因为尺寸可能不同)
|
| 680 |
await page.setViewport({ width, height });
|
| 681 |
|
| 682 |
+
// 设置内容,增加超时时间以解决Network.enable超时问题
|
| 683 |
await page.setContent(htmlContent, {
|
| 684 |
waitUntil: 'networkidle0',
|
| 685 |
+
timeout: Math.min(timeout, 20000) // 增加超时时间,解决网络连接超时问题
|
| 686 |
});
|
| 687 |
|
| 688 |
// 等待字体加载
|