Repository navigation
fix(ollama): release failed setup response bodies before returning - #111802
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 5:18 AM ET / 09:18 UTC. ClawSweeper reviewWhat this changesThis PR cancels unused HTTP response streams during Ollama cloud-auth, model-pull, and capability-scan setup exits, with regression tests for the affected paths. Merge readiness✅ Ready for maintainer review Keep this PR open for its normal human review/merge path: the latest prepared head removes the earlier release-owned changelog concern while retaining a narrow, well-tested fix for unused Ollama setup response streams. Likely related people:
Priority: P2 Review scores
Verification
How this fits togetherThe Ollama extension drives setup and onboarding requests through a guarded HTTP client. These requests either consume response data for progress/auth decisions or return early; the changed cleanup ensures unused response streams release their connection before the setup flow returns a result. flowchart LR
Operator[Operator setup or onboarding] --> Setup[Ollama setup flow]
Setup --> GuardedFetch[Guarded HTTP request]
GuardedFetch --> Response[Ollama HTTP response]
Response --> Decision{Body consumed?}
Decision -->|No| Cleanup[Cancel unused response stream]
Decision -->|Yes| Parse[Parse auth or pull result]
Cleanup --> Outcome[Return setup outcome]
Parse --> Outcome
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +4, Tests +210. Total +214 across 3 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Merge the current narrow cleanup and regression coverage after the ordinary protected human-review gate; it preserves setup outcomes while promptly releasing response streams that no caller consumes. Do we have a high-confidence way to reproduce the issue? Yes, with high confidence from source and the supplied after-fix keep-alive HTTP-server probe: the relevant early returns leave the response body unused, and the probe reports the socket is released after cancellation. This read-only review did not rerun the probe locally. Is this the best way to solve the issue? Yes. Cancelling the unused stream at the response-owning early exits is narrower and safer than changing the guarded-fetch abstraction, and it preserves existing auth, pull, and error-result behavior. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against f03dc9785e48. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
@clawsweeper automerge |
|
🦞🧹
Draft PRs stay fix-only until GitHub marks them ready for review. Pause with Automerge progress:
Re-review progress:
|
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
* repair/pr-111802-preserve: (3263 commits) test: type session request parameters (openclaw#116713) fix: retain event invalidation for pagination docs: note queued session refresh fix fix: preserve queued session refresh options fix(exec): require approval for abbreviated inline eval flags [AI] (openclaw#116529) fix: keep owner-only tools out of non-owner skill commands [AI] (openclaw#116532) fix(ui): bound Talk relay microphone uplink fix(tui): require a fresh agent roster (openclaw#116715) fix(memory-wiki): preserve user edits when rolling back ChatGPT imports (openclaw#116517) fix(agents): cron failures preserve timeout and cancellation reasons (openclaw#116566) fix(release): unblock beta validation workflows (openclaw#116708) fix(ci): discover frozen target startup benchmark cases (openclaw#116711) fix(session): preserve reset message payloads (openclaw#116195) fix(qa): tolerate loaded-runner bus delivery stalls (openclaw#116448) improve(ci): rebalance embedded agent test configs (openclaw#116436) fix(browser): return committed trace path (openclaw#116702) fix(qa): exceed Slack table aggregate limit in fallback probe (openclaw#116447) fix(qa): use built plugin tools server (openclaw#116442) fix(test): keep memory FD repro config valid (openclaw#116698) fix(telegram): keep queued tool progress in one message (openclaw#116685) ...
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
The release-owned CHANGELOG edit has been removed. The exact prepared head keeps the tested response-body release fix; 57 focused tests, real socket proof, targeted checks, and fresh autoreview are clean. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* origin/main: (1976 commits) fix(ollama): models advertise tools when /api/show fails (openclaw#109971) fix(ollama): use CJK-aware char estimate for usage fallback (openclaw#110073) fix(ollama): release failed setup response bodies before returning (openclaw#111802) feat(plugins): externalize Synthetic provider (openclaw#116720) fix(agents): unblock channel turns after restart recovery (openclaw#116728) fix(telegram): keep typing alive during active steered tasks (openclaw#116721) fix(gateway): admit standalone MCP app work (openclaw#116727) fix(googlechat): record canonical receipt thread (openclaw#116717) test(ui): cover the Talk relay start-stop race fix(ui): close superseded Talk allocations fix(agents): resume interrupted turns past progress commentary (openclaw#116725) fix(gateway): sign device proofs with challenge time (openclaw#116679) fix(testing): load relay smoke through UI Vite config test(testing): guard realtime relay smoke module path fix(testing): repair realtime relay live smoke import test: type session request parameters (openclaw#116713) fix: retain event invalidation for pagination docs: note queued session refresh fix fix: preserve queued session refresh options fix(exec): require approval for abbreviated inline eval flags [AI] (openclaw#116529) ...
* commit 'refs/frozen/talk-pcm-output-main': (21 commits) fix(agents): compact session status change text (#116742) fix(llama-cpp): recover plaintext tool calls (#116736) fix(telegram): validate native queue arguments before fallback (#116726) chore(skills): add autonomous issue sweep workflow docs(auto-qa): require clean root-cause refactors fix(ollama): models advertise tools when /api/show fails (#109971) fix(ollama): use CJK-aware char estimate for usage fallback (#110073) fix(ollama): release failed setup response bodies before returning (#111802) feat(plugins): externalize Synthetic provider (#116720) fix(agents): unblock channel turns after restart recovery (#116728) fix(telegram): keep typing alive during active steered tasks (#116721) fix(gateway): admit standalone MCP app work (#116727) test(ui): cover the Talk relay start-stop race fix(ui): close superseded Talk allocations test(google): cover expired CLI OAuth compatibility docs(google): document supported auth paths fix(ui): clarify blocked inference setup fix(google): guide broken CLI profiles to supported auth fix(onboarding): hide unsupported Google CLI setup routes fix(google): retire Gemini CLI OAuth setup ...
* origin/main: (38 commits) fix(agents): compact session status change text (#116742) fix(llama-cpp): recover plaintext tool calls (#116736) fix(telegram): validate native queue arguments before fallback (#116726) chore(skills): add autonomous issue sweep workflow docs(auto-qa): require clean root-cause refactors fix(ollama): models advertise tools when /api/show fails (#109971) fix(ollama): use CJK-aware char estimate for usage fallback (#110073) fix(ollama): release failed setup response bodies before returning (#111802) feat(plugins): externalize Synthetic provider (#116720) fix(agents): unblock channel turns after restart recovery (#116728) fix(telegram): keep typing alive during active steered tasks (#116721) fix(gateway): admit standalone MCP app work (#116727) fix(googlechat): record canonical receipt thread (#116717) test(ui): cover the Talk relay start-stop race fix(ui): close superseded Talk allocations fix(agents): resume interrupted turns past progress commentary (#116725) fix(gateway): sign device proofs with challenge time (#116679) test(google): cover expired CLI OAuth compatibility fix(testing): load relay smoke through UI Vite config test(testing): guard realtime relay smoke module path ...
…penclaw#111802) * fix(ollama): release failed setup response bodies before returning * chore(changelog): remove release-owned entry --------- Co-authored-by: Vincent Koc <[email protected]>
* commit 'refs/frozen/talk-pcm-output-main': (21 commits) fix(agents): compact session status change text (openclaw#116742) fix(llama-cpp): recover plaintext tool calls (openclaw#116736) fix(telegram): validate native queue arguments before fallback (openclaw#116726) chore(skills): add autonomous issue sweep workflow docs(auto-qa): require clean root-cause refactors fix(ollama): models advertise tools when /api/show fails (openclaw#109971) fix(ollama): use CJK-aware char estimate for usage fallback (openclaw#110073) fix(ollama): release failed setup response bodies before returning (openclaw#111802) feat(plugins): externalize Synthetic provider (openclaw#116720) fix(agents): unblock channel turns after restart recovery (openclaw#116728) fix(telegram): keep typing alive during active steered tasks (openclaw#116721) fix(gateway): admit standalone MCP app work (openclaw#116727) test(ui): cover the Talk relay start-stop race fix(ui): close superseded Talk allocations test(google): cover expired CLI OAuth compatibility docs(google): document supported auth paths fix(ui): clarify blocked inference setup fix(google): guide broken CLI profiles to supported auth fix(onboarding): hide unsupported Google CLI setup routes fix(google): retire Gemini CLI OAuth setup ...
* origin/main: (38 commits) fix(agents): compact session status change text (openclaw#116742) fix(llama-cpp): recover plaintext tool calls (openclaw#116736) fix(telegram): validate native queue arguments before fallback (openclaw#116726) chore(skills): add autonomous issue sweep workflow docs(auto-qa): require clean root-cause refactors fix(ollama): models advertise tools when /api/show fails (openclaw#109971) fix(ollama): use CJK-aware char estimate for usage fallback (openclaw#110073) fix(ollama): release failed setup response bodies before returning (openclaw#111802) feat(plugins): externalize Synthetic provider (openclaw#116720) fix(agents): unblock channel turns after restart recovery (openclaw#116728) fix(telegram): keep typing alive during active steered tasks (openclaw#116721) fix(gateway): admit standalone MCP app work (openclaw#116727) fix(googlechat): record canonical receipt thread (openclaw#116717) test(ui): cover the Talk relay start-stop race fix(ui): close superseded Talk allocations fix(agents): resume interrupted turns past progress commentary (openclaw#116725) fix(gateway): sign device proofs with challenge time (openclaw#116679) test(google): cover expired CLI OAuth compatibility fix(testing): load relay smoke through UI Vite config test(testing): guard realtime relay smoke module path ...
What Problem This Solves
Fixes a connection leak where Ollama setup flows (
openclaw configure/ onboarding model pull, cloud auth check, and the tools-capability scan) would leave the HTTP response body unread when a/api/me,/api/pull, or/api/showcall returned a non-OK status — or, for/api/me, even on success. With a slow or stalled Ollama server (or proxy in front of it), the keep-alive socket stays occupied after the call returns, pinning the connection in the dispatcher pool until GC.Why This Change Was Made
The repo's established contract for guarded fetches is to cancel the response body before returning on paths that do not consume it (
await response.body?.cancel().catch(() => undefined), as inextensions/huggingface/models.tsandextensions/openrouter/usage.ts, and the merged "cancel redirect relay response body before returning" fix). The SSRF guard'srelease()only closes the dispatcher — it does not drain or cancel an unread response body — so each caller owns this.extensions/ollama/src/setup.tsmissed it at four return/throw sites (/api/menon-OK and success,/api/pullnon-OK,/api/shownon-OK). Each now cancels the body first. Out of scope: other extensions — their error paths already consume the body viareadResponseTextLimitedor cancel it explicitly.User Impact
Operators running Ollama setup against a slow, stalled, or misbehaving server no longer leak sockets on failed pulls/auth checks, so repeated setup attempts cannot accumulate pinned keep-alive connections. No behavior change on happy paths beyond releasing the already-unused
/api/mesuccess body.Evidence
Real probe against the production
checkOllamaCloudAuthwith a local keep-alive HTTP stub that answersHTTP 500and then holds the response body open forever (slow-peer simulation). The probe counts client sockets still open after the call returns:Focused suite: new
extensions/ollama/src/setup-body-release.test.ts4/4 pass (all 4 fail againstupstream/main'ssetup.ts); fullextensions/ollama/src/setup.test.ts37/37 pass unchanged; oxlint/oxfmt clean.Real behavior proof
/api/me,/api/pull,/api/show) or a successful/api/meleaked the keep-alive connection because the unread response body was never cancelled before returning.main(7fe1d70), productioncheckOllamaCloudAuthfromextensions/ollama/src/setup.tsagainst a real localnode:httpkeep-alive server.HTTP 500for/api/meand streams an unbounded body, called the realcheckOllamaCloudAuth("http://127.0.0.1:<port>")vianode --import tsx probe.mjs, then counted client sockets still open one second after the call returned.{ signedIn: false }as before, but the client socket is released immediately (0 still open, vs 1 leaked before the patch). Regression tests confirm the same for the/api/pulland/api/showerror paths and the/api/mesuccess path.ollama pull); the probe and tests exercise the exact fetch/return paths with realResponsestreams and a real HTTP server.Regression test plan
extensions/ollama/src/setup-body-release.test.ts(new companion file; kept out ofsetup.test.ts, which already exceeds the repo's max-lines budget onmain)/api/menon-OK,/api/mesuccess,/api/pullHTTP 500,/api/showHTTP 500 during the tools scan), aResponsewhose body stream stays open until cancelled must be cancelled before the function returns or throws.Risk checklist