Repository navigation
fix: release stalled captured provider responses promptly - #130804
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 5:53 AM ET / 09:53 UTC. ClawSweeper reviewWhat this changesThe branch makes unused captured HTTP response cleanup non-blocking and preserves caller cancellation when guarded fetch also applies a timeout. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessKeep this maintainer-owned PR open: the shared transport repair is coherent and has no actionable code finding, but exact-head validation against the pinned runtime is still incomplete. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherGuarded fetch validates provider, catalog, and media URLs before dispatching them through pinned HTTP transports. Its response-release callback must clean up one request without stalling or interrupting other requests that share a dispatcher. flowchart LR
A[Provider or media caller] --> B[Guarded HTTP request]
B --> C[URL and redirect validation]
C --> D[Pinned dispatcher]
D --> E[Captured response]
E --> F[Release and cancellation]
F --> G[Typed result or error]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -3, Tests +344. Total +341 across 17 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Retain the shared per-hop abort and non-blocking cleanup design, and land only after exact-head CI confirms the retained pooled-TCP regression with Undici 8.10.0. Do we have a high-confidence way to reproduce the issue? Yes: the added local HTTP and pooled-dispatcher regression encodes the stalled capture and caller-signal paths, though this read-only review did not execute it. Is this the best way to solve the issue? Yes, provisionally: repairing guarded fetch and using the shared cleanup helper removes provider-local duplication while preserving redirect and pooled-dispatcher ownership; exact-head runtime validation remains required. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against dd005e53866f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
@clawsweeper re-review The corrected head also preserves caller cancellation when |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Merged via squash.
|
…30804) * fix: release stalled captured provider responses promptly * fix: preserve caller cancellation through guarded request timeouts * test: bound guarded response regression reads * test: retain owned sockets in portal collision fixtures
What Problem This Solves
Fixes an issue where users discovering LM Studio models, reading live provider catalogs, or authenticating GitHub Copilot could wait for an unused error response body when HTTP capture retained a clone. Redirects could also stall before proceeding or reporting a missing/blocked destination.
Also fixes in-flight caller cancellation being lost when a guarded request supplies
init.signalalongside a timeout, including native PDF requests. The caller signal must be selected before composing the deadline, rather than being replaced by its generated signal.Why This Change Was Made
Cancellation of one branch of a cloned response can remain pending until the capture branch finishes. Unread-body cleanup now requests cancellation without waiting for that unrelated consumer. The guarded request owns a fresh abort controller for each redirect hop and ends only that hop before returning its dispatcher lease. This also bounds the abandoned transport rather than merely making the status error prompt.
The core cancellation helper remains the canonical internal flow; duplicate one-use LM Studio and Copilot helpers are removed. Custom fetch implementations still receive response cancellation even if they ignore abort signals. Caller cancellation and its reason work with and without a timeout; an explicit top-level signal retains precedence over
init.signal. Redirect authorization, pooled sibling requests, and completed captures are preserved. The publicrelease(): Promise<void>signature and the shipped generic dispatcher graceful-close API are unchanged; no config, dependency, or storage changes are included.The guard's awaited redirect cancellation is traceable to #121687, commit f09a33c (2026-08-10; code/PR author and merger: @steipete). This identifies that guard regression, not a common origin for every affected provider helper.
User Impact
Known HTTP failures and redirects settle promptly while guarded abandoned requests release their transport. Other in-flight requests sharing the same dispatcher and caller signal remain usable. Copilot's unguarded authentication request keeps its existing timeout/capture limits; this change promises prompt typed authentication errors, not immediate closure of that separate capture stream.
Callers can also cancel an in-flight request that combines a request-option signal with a deadline. The native PDF path is a current-main example, not a claimed stable-release PDF regression.
Existing reader-cancellation-before-release paths in streaming wrappers and prefix readers remain separate follow-ups. This is not a claim that all capture or streaming cancellation paths are repaired.
Evidence
Reviewed corrective head:
fe2cb3cd0f28a607a435699576c3c3a95639e598.init.signalplus timeout failed; afterward all six passed.Responsefixtures. The corrections preserve admission-live/owned-release-aborted state, cleared timer ownership, byte caps, cancellation, and media payload/error assertions using real response streams; no production fallback or weaker lint rule was added.9b9ab4a461529a1b4df9b38b268ea898b8de8d08passed after one unchanged failed-job retry. Its first attempt had doctor process/hook timeouts amid broad 8–9× slowdown; the cause remains unknown, and the entire seven-group job plus gate passed on retry. The separate OpenGrep scan flagged five direct response reads in our owned test fixtures. Those reads now use the existing 32-byte bounded whole-body reader, with no new timer, truncation, suppression, or scan exclusion. Against the original guard, the modified tests still produced the four intended release/cancellation/redirect failures while 113 controls passed; restoring the candidate passed all 117, then the 167-test reader/guard scope.EADDRINUSEerror instead of the expected ten-collision terminal error. This was an intra-case allocation-order proof, not a full-file or cross-test culprit claim. The two fixtures now hold an owned target, leave actual socket allocation at port zero, and inject only the one-shot reported address needed to exercise collision handling. All ten attempts, real listener shutdown, both bind hosts, and exact bounded HTTP forwarding remain proved. The complete portal service/proxy files passed 36 tests before and after, and targeted type-aware lint passed. No production retry or timeout was changed. Fresh full-patch P0–P2 and independent source/proof review, including this final test correction, found no actionable issues.src/gateway/portals/portal-http-proxy.test.ts:513is a named follow-up, not fixed here; the deterministic worker failure cases remain unchanged.