Skip to content

fix(web): 给 searchBing 添加 15s 超时防止无限挂起#2252

Merged
esengine merged 2 commits into
esengine:mainfrom
zhangyapu1:fix/bing-search-timeout
May 29, 2026
Merged

fix(web): 给 searchBing 添加 15s 超时防止无限挂起#2252
esengine merged 2 commits into
esengine:mainfrom
zhangyapu1:fix/bing-search-timeout

Conversation

@zhangyapu1

Copy link
Copy Markdown

问题

Bing 搜索函数 searchBing 缺少超时机制。当 Bing 响应缓慢或连接被墙时,fetch 请求会无限挂起,导致 web search 工具卡死在 research 步骤,用户必须手动终止进程。

修复

searchBingfetch 调用添加 AbortSignal.timeout(15_000)(15 秒超时),与外部传入的 opts.signal 通过 AbortSignal.any() 组合使用。超时后会正确抛出 TimeoutError,与其他搜索引擎(Tavily、Perplexity 等已有的超时机制)行为一致。

改动文件:src/tools/web.ts(+3 行,-1 行)


Problem

The searchBing function had no timeout mechanism. When Bing responds slowly or the connection is blocked, the fetch request 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) to searchBing's fetch call, combined with the external opts.signal via AbortSignal.any(). On timeout, a TimeoutError is 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

zhangyapu1 and others added 2 commits May 29, 2026 15:35
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>
@zhangyapu1 zhangyapu1 mentioned this pull request May 29, 2026
Closed

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 esengine merged commit bd98ef3 into esengine:main May 29, 2026
4 checks passed
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.
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.

需要联网搜索时,会执行很多次web search和web fetch,最后卡到tool research就不动了

2 participants