fix(web): 给 searchBing 添加 15s 超时防止无限挂起#2252
Merged
Merged
Conversation
Bing 搜索缺少 AbortSignal.timeout(),响应慢或被墙时请求会无限挂起, 导致 web search 工具卡死在 research 步骤。添加 15 秒超时并与外层 signal 组合。 fix(web): add 15s timeout to searchBing to prevent infinite hangs Bing search lacked AbortSignal.timeout(), causing infinite hangs on slow responses or blocked connections. This left the web search tool stuck in the research step. Add a 15s timeout combined with the outer signal. Closes esengine#2241 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Closed
esengine
approved these changes
May 29, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
Correct fix for the hang: wraps searchBing's fetch with AbortSignal.timeout(15_000), and uses AbortSignal.any([opts.signal, timeoutSignal]) so the caller's existing cancellation signal is preserved rather than dropped. Clean, CI green. LGTM.
esengine
pushed a commit
that referenced
this pull request
May 29, 2026
…2259) #2252 added a 15s AbortSignal.timeout to searchBing; the other engines (Searxng, Metaso, Baidu, Tavily, Perplexity, Exa, Ollama, Brave) still relied on opts.signal only and could hang indefinitely. Extract searchSignal() helper that combines the caller's abort signal with a per-request SEARCH_TIMEOUT_MS cap, and apply it uniformly.
This was referenced May 29, 2026
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.
问题
Bing 搜索函数
searchBing缺少超时机制。当 Bing 响应缓慢或连接被墙时,fetch请求会无限挂起,导致 web search 工具卡死在 research 步骤,用户必须手动终止进程。修复
给
searchBing的fetch调用添加AbortSignal.timeout(15_000)(15 秒超时),与外部传入的opts.signal通过AbortSignal.any()组合使用。超时后会正确抛出TimeoutError,与其他搜索引擎(Tavily、Perplexity 等已有的超时机制)行为一致。改动文件:
src/tools/web.ts(+3 行,-1 行)Problem
The
searchBingfunction had no timeout mechanism. When Bing responds slowly or the connection is blocked, thefetchrequest hangs indefinitely, leaving the web search tool stuck in the research step and forcing users to manually kill the process.Fix
Add
AbortSignal.timeout(15_000)(15s timeout) tosearchBing'sfetchcall, combined with the externalopts.signalviaAbortSignal.any(). On timeout, aTimeoutErroris thrown — consistent with the timeout behavior already present in other search engines (Tavily, Perplexity, etc.).Changed file:
src/tools/web.ts(+3 lines, -1 line)Closes #2241