smart-image-scraper-mcp 1.1.1 → 1.1.3
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
|
@@ -9,7 +9,7 @@ import logger from '../infrastructure/logger.js';
|
|
|
9
9
|
import config from '../config/index.js';
|
|
10
10
|
|
|
11
11
|
// 全局共享的并发限制器,避免多个请求同时发起导致资源竞争
|
|
12
|
-
const globalValidateLimit = pLimit(
|
|
12
|
+
const globalValidateLimit = pLimit(5); // 限制验证并发为 5
|
|
13
13
|
|
|
14
14
|
export class LinkValidator {
|
|
15
15
|
constructor() {
|
|
@@ -12,8 +12,8 @@ import logger from '../infrastructure/logger.js';
|
|
|
12
12
|
import config from '../config/index.js';
|
|
13
13
|
|
|
14
14
|
// 全局共享的并发限制器,避免多个 MCP 请求同时发起导致资源竞争
|
|
15
|
-
const globalKeywordLimit = pLimit(
|
|
16
|
-
const globalRequestLimit = pLimit(
|
|
15
|
+
const globalKeywordLimit = pLimit(1); // 严格限制关键词并发
|
|
16
|
+
const globalRequestLimit = pLimit(1); // 严格限制同时只处理 1 个 MCP 请求
|
|
17
17
|
|
|
18
18
|
export class Orchestrator {
|
|
19
19
|
constructor() {
|
|
@@ -212,7 +212,20 @@ export class Orchestrator {
|
|
|
212
212
|
* @returns {Promise<Object>} - 执行结果
|
|
213
213
|
*/
|
|
214
214
|
async execute(params) {
|
|
215
|
-
//
|
|
215
|
+
// 检查当前队列状态
|
|
216
|
+
const pendingCount = this.requestLimit.pendingCount;
|
|
217
|
+
const activeCount = this.requestLimit.activeCount;
|
|
218
|
+
|
|
219
|
+
// 如果队列中已有等待的请求,直接返回提示(避免长时间等待)
|
|
220
|
+
if (pendingCount > 0) {
|
|
221
|
+
logger.warn(`Request queued: ${pendingCount} pending, ${activeCount} active`);
|
|
222
|
+
return {
|
|
223
|
+
success: false,
|
|
224
|
+
error: `当前有 ${pendingCount + activeCount} 个请求正在处理中,请稍后重试。建议一次只发起一个搜索请求。`,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// 使用全局请求限制器
|
|
216
229
|
return this.requestLimit(() => this._executeInternal(params));
|
|
217
230
|
}
|
|
218
231
|
|