Skip to content

fix: qa-agent fetch 调用添加 AbortController#5

Open
alloevil wants to merge 1 commit into
mainfrom
fix/agent-fetch-abort
Open

fix: qa-agent fetch 调用添加 AbortController#5
alloevil wants to merge 1 commit into
mainfrom
fix/agent-fetch-abort

Conversation

@alloevil

@alloevil alloevil commented Jul 8, 2026

Copy link
Copy Markdown
Owner

问题

qa-agent.mjscallLLMrerankByLLM 使用 fetch 发起 HTTP 请求,外层用 withTimeout 包裹做超时控制。但 withTimeout 只是 race 了一个 rejection,底层的 fetch 连接并不会被关闭——如果服务端不响应,连接会一直挂着,浪费资源。

修复

  • callLLM:添加 AbortController,28s 超时(略小于外层 withTimeout(30s)),确保在外层 timeout 前主动断开
  • rerankByLLM:添加 AbortController,20s 超时
  • ✅ 两者都用 try/finally 清理 timeout,防止泄漏

- callLLM: add AbortController with 28s timeout (less than outer withTimeout 30s)
  so the fetch connection is properly terminated when the agent times out
- rerankByLLM: add AbortController with 20s timeout
- Both use try/finally to clean up the timeout

Previously, when withTimeout() fired the underlying fetch connection would
remain open, leaking resources.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant