fix: qa-agent fetch 调用添加 AbortController#5
Open
alloevil wants to merge 1 commit into
Open
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
qa-agent.mjs中callLLM和rerankByLLM使用fetch发起 HTTP 请求,外层用withTimeout包裹做超时控制。但withTimeout只是 race 了一个 rejection,底层的fetch连接并不会被关闭——如果服务端不响应,连接会一直挂着,浪费资源。修复
callLLM:添加AbortController,28s 超时(略小于外层withTimeout(30s)),确保在外层 timeout 前主动断开rerankByLLM:添加AbortController,20s 超时try/finally清理 timeout,防止泄漏