Skip to content

fix(docs): cancel non-OK search response body before throwing - #109508

Merged
steipete merged 1 commit into
openclaw:mainfrom
Monkey-wusky:fix/docs-cancel-error-response-body
Jul 17, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
Monkey-wusky:fix/docs-cancel-error-response-body

Conversation

@Monkey-wusky

Copy link
Copy Markdown
Contributor

What Problem This Solves

When fetchDocsSearch receives a non-OK response from the Cloudflare docs search API, it throws immediately without cancelling the response body. This leaves the underlying HTTP connection open until the response body is garbage-collected, which can delay connection reuse.

Why This Change Was Made

Other parts of the codebase already cancel non-OK response bodies before throwing — see fetchOpenRouterModels in model-scan.ts (finally block) and guard-adapters.ts (#109196). This change applies the same pattern to fetchDocsSearch for consistency.

User Impact

No visible user impact. The fix ensures connections are released promptly on API errors, which can improve responsiveness when the docs search API is degraded.

Evidence

Test: cancels non-OK docs search response bodies and fails loudly

✓ cancels non-OK docs search response bodies and fails loudly 5ms

The test creates a Response("unavailable", { status: 503 }), spies on response.body.cancel, and verifies:

  1. cancel is called exactly once before the error propagates
  2. The CLI still reports the error and exits with code 1

All 5 docs command tests pass:

 ✓ calls the Cloudflare docs search API
 ✓ cancels non-OK docs search response bodies and fails loudly
 ✓ reports malformed docs search JSON with CLI context
 ✓ renders successful results from the Cloudflare docs search API
 ✓ rejects oversized docs search responses

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS labels Jul 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 1:53 AM ET / 05:53 UTC.

Summary
The PR cancels a non-OK docs-search response body before throwing and extends the command test to assert cancellation.

PR surface: Source +1, Tests +13. Total +14 across 2 files.

Reproducibility: no. not at high confidence: source inspection and the mocked regression establish the cancellation path, but no current-head real HTTP reproduction demonstrates the underlying connection behavior.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

  • [P1] Add redacted loopback HTTP proof showing the server observes peer closure after a partial or stalled non-OK response.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR shows only a mocked Response/ReadableStream test; before merge, add redacted loopback HTTP output or logs showing that a real server observes peer closure, then update the PR body to trigger re-review or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] The mocked ReadableStream proves that cancel() is invoked, but it does not establish that Node's real HTTP transport promptly closes or releases a partial stalled non-OK response connection.

Maintainer options:

  1. Decide the mitigation before merge
    Retain the narrow owner-boundary cleanup and add a real loopback HTTP transcript where the docs command receives a partial or stalled 503 response and the server observes peer closure, with private endpoints and network details redacted.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The only remaining blocker is contributor-owned real behavior evidence, not a concrete code defect suitable for an automated repair worker.

Security
Cleared: The focused runtime and test changes introduce no concrete security or supply-chain concern.

Review details

Best possible solution:

Retain the narrow owner-boundary cleanup and add a real loopback HTTP transcript where the docs command receives a partial or stalled 503 response and the server observes peer closure, with private endpoints and network details redacted.

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

No, not at high confidence: source inspection and the mocked regression establish the cancellation path, but no current-head real HTTP reproduction demonstrates the underlying connection behavior.

Is this the best way to solve the issue?

Yes, cancelling the unread body at the fetch owner boundary before preserving the existing error is the narrowest maintainable fix; only transport-level proof remains missing.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: This is a narrow resource-cleanup fix with no claimed visible user impact and limited command-path blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR shows only a mocked Response/ReadableStream test; before merge, add redacted loopback HTTP output or logs showing that a real server observes peer closure, then update the PR body to trigger re-review or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +1, Tests +13. Total +14 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 0 +1
Tests 1 15 2 +13
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 16 2 +14

What I checked:

  • Current-head implementation: The current head awaits cancellation of the unread response body, suppresses cancellation errors, and then preserves the existing HTTP-status error path. (src/commands/docs.ts:78, 0a8da3bc08ed)
  • Focused regression coverage: The updated test supplies a non-OK ReadableStream response and verifies that its cancellation callback runs while the CLI still reports HTTP 503 and exits with code 1. (src/commands/docs.test.ts:68, 0a8da3bc08ed)
  • Proof remains mock-only: The PR evidence reports the mocked Response test suite but does not include a loopback HTTP run, transport logs, or server-side observation of peer closure on the current head. (src/commands/docs.test.ts:68, 0a8da3bc08ed)
  • Established sibling pattern: The merged Reef PR used the same non-OK response ownership rule and supplied stronger loopback proof in which a server observed the peer closing after a partial stalled 503 response. (extensions/reef/protocol/guard-adapters.ts, 2cd236385b30)
  • Re-review continuity: Earlier ClawSweeper cycles raised no code finding and requested real behavior proof; the current head retains the same narrow implementation and still lacks that proof in the hydrated PR body. (68ad3c541736)

Likely related people:

  • steipete: The timeline shows steipete force-pushed the latest reviewed head after the proof request, making them the clearest current routing contact for this PR state. (role: recent branch updater; confidence: medium; commits: 0a8da3bc08ed; files: src/commands/docs.ts, src/commands/docs.test.ts)
  • zhangguiping-xydt: Their merged Reef change established and proved the same response-body cancellation invariant for non-success HTTP responses. (role: adjacent behavior contributor; confidence: medium; commits: 2cd236385b30; files: extensions/reef/protocol/guard-adapters.ts, extensions/reef/protocol/guard.test.ts)
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 (2 earlier review cycles)
  • reviewed 2026-07-17T01:46:20.984Z sha 1e3368b9efd8ca29ea5aea7a1d94c78fba712d35 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T03:37:22.465Z sha 68ad3c5 :: needs real behavior proof before merge. :: none

@Monkey-wusky
Monkey-wusky force-pushed the fix/docs-cancel-error-response-body branch from 1e3368b to 68ad3c5 Compare July 17, 2026 03:30
When the Cloudflare docs search API returns a non-OK status,
fetchDocsSearch threw without cancelling the response body.
This could leave the underlying connection open until GC.

Cancel the body before throwing, matching the pattern established
in reef guard adapters (openclaw#109196) and fetchOpenRouterModels.
@steipete
steipete force-pushed the fix/docs-cancel-error-response-body branch from 68ad3c5 to 0a8da3b Compare July 17, 2026 05:47
@steipete
steipete merged commit a8fd558 into openclaw:main Jul 17, 2026
119 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

@Monkey-wusky
Monkey-wusky deleted the fix/docs-cancel-error-response-body branch July 17, 2026 06:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…aw#109508)

When the Cloudflare docs search API returns a non-OK status,
fetchDocsSearch threw without cancelling the response body.
This could leave the underlying connection open until GC.

Cancel the body before throwing, matching the pattern established
in reef guard adapters (openclaw#109196) and fetchOpenRouterModels.
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…aw#109508)

When the Cloudflare docs search API returns a non-OK status,
fetchDocsSearch threw without cancelling the response body.
This could leave the underlying connection open until GC.

Cancel the body before throwing, matching the pattern established
in reef guard adapters (openclaw#109196) and fetchOpenRouterModels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants