Repository navigation
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close this PR as superseded by #102897. So I’m closing this here and keeping the remaining discussion on #102897. Review detailsDo we have a high-confidence way to reproduce the issue? Yes, source-reproducible with high confidence: current Is this the best way to solve the issue? Yes for the code shape: using the existing Security review: Security review cleared: The diff only adds a timeout parameter to an existing guarded, capture-disabled QQBot token request and introduces no dependency, workflow, permission, SSRF-policy, or secret-handling change. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 3c048ef05297. |
|
ClawSweeper applied the proposed close for this PR.
|
What Problem This Solves
TokenManager.doFetchTokeninextensions/qqbot/src/engine/api/token.tscallsfetchWithSsrFGuardto POST credentials tohttps://bots.qq.com/app/getAppAccessTokenwithout a
timeoutMsor top-levelsignal. Ifbots.qq.comaccepts the TCP connectionbut never sends an HTTP response (stalled server, network middlebox, or proxy delay), the
token fetch hangs indefinitely.
This is especially impactful because the token endpoint is on the critical path for every
authenticated QQBot API call. Every message send, API call, and upload eventually calls
getAccessToken, which goes throughdoFetchTokenwhen the cache is empty or expired.A stalled token fetch blocks all QQBot operations with no timeout error surfaced.
The sibling
ApiClient.requestmethod andexecuteChannelApiboth implement 30-secondtimeouts via
AbortController+signal. Thestt.tstranscription helper passestimeoutMsdirectly.doFetchTokenwas the only call site with no timeout of any kind.Why This Change Was Made
fetchWithSsrFGuardaccepts a top-leveltimeoutMsparameter (defined insrc/infra/net/fetch-guard.ts:80). AddingtimeoutMs: QQBOT_TOKEN_TIMEOUT_MSto thesingle
fetchWithSsrFGuardcall site indoFetchTokencloses the gap. The 30-secondconstant matches the
DEFAULT_TIMEOUT_MSused inApiClientandchannel-api.ts,keeping the timeout policy consistent across all QQBot HTTP call sites.
User Impact
Before: If
bots.qq.comaccepts but never answers, every QQBot operation requiringauth hangs indefinitely — no timeout error, no lane release. Under concurrent usage,
multiple stalled token fetches accumulate and singleflight collapses them into one pending
promise, but that promise also never resolves.
After:
doFetchTokenfails with an abort/timeout error after 30 seconds. The callerreceives a concrete network error, the lane is released, and the singleflight map is
cleared. Subsequent calls can retry.
Evidence
Branch:
fix/qqbot-token-fetch-timeoutBase:
upstream/main(9775f09194)Node: v22.22.0 — macOS Darwin 24.3.0 arm64
Regression tests
7 tests pass: the 6 pre-existing cases (including the RFC 2544 SSRF regression for #88984)
plus the new
"passes timeoutMs to fetchWithSsrFGuard on every token fetch"case.The existing
"wraps malformed access token JSON"test uses an exacttoHaveBeenCalledWithassertion — it now includes
timeoutMs: 30_000and still passes, confirming the field isforwarded on real calls.
Source-level proof
QQBOT_TOKEN_TIMEOUT_MS = 30_000is defined intoken.tsand forwarded astimeoutMsin the single
fetchWithSsrFGuardcall indoFetchToken. No other call sites areaffected; the other QQBot
fetchWithSsrFGuardcallers already implement timeout viaAbortController+signal(api-client.ts, channel-api.ts, media-chunked.ts, media.ts)or
timeoutMs(stt.ts).Diff summary
Reproduction sketch (end-to-end, not run)
never emits an HTTP response.
bots.qq.comto that server via/etc/hosts.doFetchTokennever resolves — all QQBot operations stall indefinitely.receives
"Network error getting access_token: ...", gateway can continue.What was not tested: live
bots.qq.comstall scenario with a real QQ Bot application.Crabbox/Testbox remote CI was not available at submission time.