smart-image-scraper-mcp 2.9.1 → 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -346,16 +346,20 @@ export class Orchestrator {
|
|
|
346
346
|
async execute(params) {
|
|
347
347
|
metrics.recordRequest();
|
|
348
348
|
const requestId = `req_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`;
|
|
349
|
-
|
|
349
|
+
|
|
350
|
+
// 根据关键词数量动态计算超时时间(每个关键词 10 秒,最少 30 秒,最多 120 秒)
|
|
351
|
+
const keywords = this.parseKeywords(params.query);
|
|
352
|
+
const keywordCount = keywords.length;
|
|
353
|
+
const GLOBAL_TIMEOUT = Math.min(Math.max(keywordCount * 10000, 30000), 120000);
|
|
350
354
|
|
|
351
355
|
try {
|
|
352
|
-
logger.info(`[Orchestrator] Starting request: ${requestId}`);
|
|
356
|
+
logger.info(`[Orchestrator] Starting request: ${requestId}, keywords: ${keywordCount}, timeout: ${GLOBAL_TIMEOUT/1000}s`);
|
|
353
357
|
|
|
354
358
|
// 添加全局超时熔断机制
|
|
355
359
|
const result = await Promise.race([
|
|
356
360
|
this._executeInternal(params),
|
|
357
361
|
new Promise((_, reject) =>
|
|
358
|
-
setTimeout(() => reject(new Error(
|
|
362
|
+
setTimeout(() => reject(new Error(`REQUEST_TIMEOUT: 请求超时(${GLOBAL_TIMEOUT/1000}秒),关键词过多请减少数量`)), GLOBAL_TIMEOUT)
|
|
359
363
|
)
|
|
360
364
|
]);
|
|
361
365
|
|