缺陷 / 高 / 工具系统
electron/harness/tools/registry.ts
工具定义中 timeoutMs 是可选字段。当工具未设置 timeoutMs 时,setTimeout(fn, undefined) 实际上等同于 setTimeout(fn, 0),导致:
timeoutMs
setTimeout(fn, undefined)
setTimeout(fn, 0)
// 修改前 const timer = setTimeout(() => reject(...), tool.timeoutMs); // 修改后 const timeout = tool.timeoutMs ?? this.defaultTimeoutMs ?? 120_000; if (typeof timeout !== 'number' || timeout <= 0) { throw new Error(`Invalid timeoutMs: ${tool.timeoutMs}`); } const timer = setTimeout(() => reject(...), timeout);
并在 ToolDef 类型定义时强制类型检查。
No dependencies set.
The note is not visible to the blocked user.
问题类型
缺陷 / 高 / 工具系统
文件位置
electron/harness/tools/registry.ts问题描述
工具定义中
timeoutMs是可选字段。当工具未设置timeoutMs时,setTimeout(fn, undefined)实际上等同于setTimeout(fn, 0),导致:影响
建议修复
并在 ToolDef 类型定义时强制类型检查。