Skip to content

fix(qqbot): add 30s request timeout to token endpoint fetch - #102897

Merged
steipete merged 1 commit into
openclaw:mainfrom
maweibin:fix/qqbot-token-request-timeout
Jul 11, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
maweibin:fix/qqbot-token-request-timeout

Conversation

@maweibin

@maweibin maweibin commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

TokenManager.doFetchToken() called fetchWithSsrFGuard without a deadline. If the QQBot token endpoint accepted a connection but never returned response headers, the singleflight token request could hang indefinitely and block every caller waiting for the same app token.

Why This Change Was Made

The token endpoint now uses the existing guarded-fetch timeout contract with a 30-second deadline. The change stays in the QQBot token owner and reuses the same bounded-fetch mechanism already used elsewhere rather than adding another timer path.

User Impact

A stalled QQBot token request now aborts after 30 seconds. Every caller sharing that in-flight request receives the same timeout failure, the singleflight state is cleared, and a later request can retry normally.

Evidence

  • The owner-boundary regression drives the real TokenManager through the real guarded fetch with two same-app callers.
  • A stalled request aborts at the configured deadline; both callers reject; the in-flight status is cleared; the next request succeeds.
  • Sanitized AWS Crabbox run run_3e6b0bdb1f9e: extensions/qqbot/src/engine/api/token.test.ts, 7/7 passed.
  • Patch-identical hosted CI run 29132587977: 62 green rollup checks, no failures; native prepare accepted it after the clean rebase.
  • Fresh Codex autoreview: no accepted or actionable findings.

Live QQ platform traffic was not required for this failure class: the regression controls the stalled response at the guarded-fetch boundary while exercising production TokenManager singleflight behavior.

Root Cause

The token acquisition path was the remaining QQBot fetch path without a bounded deadline. Because TokenManager deduplicates requests per app, one stalled request also stalled every waiter.

AI-assisted.

@clawsweeper

clawsweeper Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 10, 2026, 8:34 PM ET / July 11, 2026, 00:34 UTC.

Summary
The PR adds a 30-second deadline to QQBot access-token acquisition and regression coverage for shared timeout failure, state cleanup, and retry.

PR surface: Source +2, Tests +70. Total +72 across 2 files.

Reproducibility: yes. A real loopback HTTP server accepted the request without returning headers, and the unchanged production guard path rejected near the configured deadline after the fix.

Review metrics: none identified.

Root-cause cluster
Relationship: canonical
Canonical: #102897
Summary: This is the active proof-positive QQBot token-timeout implementation; the same-path alternative closed unmerged, while the Google Chat timeout is separate channel work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P2] The PR branch is behind current main and should be refreshed before merge, although the relevant token, guard, and timeout files have no intervening drift.

Maintainer options:

  1. Decide the mitigation before merge
    Refresh the branch, rerun exact-head gates, and merge the focused call-site timeout while keeping it internal and fixed rather than adding new configuration or parallel abort machinery.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No repair-lane defect remains; this active implementation PR only needs routine branch refresh, exact-head gating, and maintainer landing.

Security
Cleared: The patch adds no dependency or execution surface and preserves the hard-coded endpoint, credential handling, permissions, and host-scoped SSRF policy.

Review details

Best possible solution:

Refresh the branch, rerun exact-head gates, and merge the focused call-site timeout while keeping it internal and fixed rather than adding new configuration or parallel abort machinery.

Do we have a high-confidence way to reproduce the issue?

Yes. A real loopback HTTP server accepted the request without returning headers, and the unchanged production guard path rejected near the configured deadline after the fix.

Is this the best way to solve the issue?

Yes. Passing the existing guard's timeoutMs at the sole unbounded token endpoint is the narrowest maintainable solution and preserves established SSRF, singleflight, retry, and configuration behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b7d6291bfd6e.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. A real stalled loopback HTTP request demonstrated the after-fix timeout, and the production token implementation is identical between that proof head and the current head.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): A real stalled loopback HTTP request demonstrated the after-fix timeout, and the production token implementation is identical between that proof head and the current head.

Label justifications:

  • P2: A stalled token endpoint blocks QQBot authenticated operations, but the affected path and blast radius are limited to one channel plugin.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): A real stalled loopback HTTP request demonstrated the after-fix timeout, and the production token implementation is identical between that proof head and the current head.
  • proof: sufficient: Contributor real behavior proof is sufficient. A real stalled loopback HTTP request demonstrated the after-fix timeout, and the production token implementation is identical between that proof head and the current head.
Evidence reviewed

PR surface:

Source +2, Tests +70. Total +72 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 0 +2
Tests 1 70 0 +70
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 72 0 +72

What I checked:

  • Current main still needs the fix: The current-main doFetchToken call uses fetchWithSsrFGuard without timeoutMs, so the central hang remains unresolved without this PR. (extensions/qqbot/src/engine/api/token.ts:245, b7d6291bfd6e)
  • Focused current-head implementation: The PR passes a fixed 30-second deadline to the existing host-scoped guarded fetch without changing configuration, retry policy, credentials handling, or the SSRF allowlist. (extensions/qqbot/src/engine/api/token.ts:251, dcc269503aba)
  • Canonical timeout contract: The shared guard composes timeoutMs into an abort signal, aborts with TimeoutError: request timed out, and clears its timer and abort listener during release. (src/utils/fetch-timeout.ts:99, b7d6291bfd6e)
  • Guard rejection cleanup: A timed-out guarded fetch releases its dispatcher and timeout resources before rethrowing, while successful token responses are released by the token manager after bounded body parsing. (src/infra/net/fetch-guard.ts:713, b7d6291bfd6e)
  • Real-proof continuity: The earlier proof head ran a real hanging loopback HTTP server; the production token.ts blob is identical between that proof head and the current PR head. (extensions/qqbot/src/engine/api/token.loopback.test.ts:37, 178754ac2f2b)
  • Current-head validation: GitHub reports the current head passing critical quality, extension boundary, lint, type, security scan, build-artifact, QA smoke, and real-behavior-proof checks. (dcc269503aba)

Likely related people:

  • steipete: Peter is the live assignee, integrated the current branch, and authored several recent token expiry, clock, and error-handling changes in this file. (role: current assignee and recent token-path contributor; confidence: high; commits: 91ecd9645f12, 6b14df7792fb, 472606de9bc2; files: extensions/qqbot/src/engine/api/token.ts, extensions/qqbot/src/engine/api/token.test.ts)
  • vincentkoc: Vincent authored recent malformed-JSON handling, response-size limits, and internal declaration cleanup for the same token manager. (role: recent token-path contributor; confidence: high; commits: d9c6036a8f53, 8594af21e999, 9e5ac0cea4aa; files: extensions/qqbot/src/engine/api/token.ts, extensions/qqbot/src/engine/api/token.test.ts)
  • cxyhhhhh: This contributor introduced the self-contained QQBot engine architecture that owns the token-manager implementation and its callers. (role: original engine architecture contributor; confidence: medium; commits: 5e72e39c1852; files: extensions/qqbot/src/engine/api/token.ts, extensions/qqbot/src/engine)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (4 earlier review cycles)
  • reviewed 2026-07-09T15:03:15.831Z sha df966af8f2d23b8893b93685bc5745f80c8ecd93 :: needs real behavior proof before merge. :: [P2] Update the token fetch expectation
  • reviewed 2026-07-10T09:13:04.241Z sha 178754ac2f2b2213634b7b334a635d3dfae1aa19 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-10T12:44:11.831Z sha 03a86a78df9a335cb6c6f9593cdaac62d7af9c9a :: needs maintainer review before merge. :: none
  • reviewed 2026-07-11T00:02:41.670Z sha af83e02c6c36ec94b699e6828e831bc7f5e5f7ca :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 9, 2026
@maweibin

Copy link
Copy Markdown
Contributor Author

Supplemented with real-behavior proof and fixed a stale unit assertion:

  • token.loopback.test.ts starts a real node:http server that accepts the connection but never sends response headers, then drives the production fetchWithSsrFGuard with the forwarded deadline. The request rejects ~500ms in (request timed out) instead of hanging (standalone measurement: rejectedAfterMs: 575).
  • Fixed the malformed-JSON test's exact toHaveBeenCalledWith expectation to include the forwarded timeoutMs, so the full token suite now passes (6/6).

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 10, 2026
@maweibin
maweibin force-pushed the fix/qqbot-token-request-timeout branch from 178754a to 03a86a7 Compare July 10, 2026 11:38
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 10, 2026
@steipete steipete self-assigned this Jul 10, 2026
@steipete
steipete force-pushed the fix/qqbot-token-request-timeout branch from 03a86a7 to af83e02 Compare July 10, 2026 23:54
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts docker Docker and sandbox tooling labels Jul 11, 2026
@steipete
steipete force-pushed the fix/qqbot-token-request-timeout branch from 12beeba to 7460e92 Compare July 11, 2026 00:13
@openclaw-barnacle openclaw-barnacle Bot removed scripts Repository scripts docker Docker and sandbox tooling labels Jul 11, 2026
@steipete
steipete force-pushed the fix/qqbot-token-request-timeout branch from 7460e92 to dcc2695 Compare July 11, 2026 00:25
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 11, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 11, 2026
@steipete

steipete commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Land-ready proof for 04538155f46c40621d1215cdca16868f89fea135.

What changed:

  • QQBot token acquisition now passes the established 30-second deadline to the guarded fetch.
  • The owner-boundary regression drives the real TokenManager and guarded fetch with two singleflight waiters, verifies shared timeout rejection and cleanup, then proves a retry succeeds.
  • The branch is one contributor-authored commit on current reviewed main; PR-local changelog and redundant loopback coverage were removed.

Validation:

Known gap: no live QQ account traffic was used. The failure is a deterministic stalled-response/singleflight condition covered at the exact production owner boundary.

@steipete
steipete force-pushed the fix/qqbot-token-request-timeout branch from dcc2695 to 0453815 Compare July 11, 2026 00:41
@steipete
steipete merged commit 6b460e5 into openclaw:main Jul 11, 2026
95 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: qqbot P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants