Repository navigation
fix(media): release rejected BytePlus and Runway video downloads under debug capture - #119257
Conversation
…r debug capture When the debug proxy is enabled it patches global fetch and clones every response, so the caller-facing body is one branch of a live tee. Cancelling such a branch settles only after both branches cancel, so awaiting it in the rejected-download path leaves the download pending instead of surfacing the malformed-response error. Both providers read the completed media URL through the global fetch, so they reach the capture clone. Switch them to the fire-and-forget release the other generated-media owners already use, and cover each with a regression that keeps a capture clone live while the download is rejected.
|
Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 12:07 PM ET / 16:07 UTC. ClawSweeper reviewWhat this changesThis PR makes BytePlus and Runway return their existing malformed-video error without waiting for a debug-captured response tee to finish cancellation. Merge readinessKeep open: current main still awaits cancellation on both affected provider paths, while the PR’s tee-safe cancellation matches existing provider behavior and the updated real-runtime proof addresses the prior proof gap. No blocking patch defect found. Priority: P2 Review scores
Verification
How this fits togetherGenerated-video providers poll a task, then download its resulting media URL. Debug capture clones global-fetch responses for recording; providers must validate the download and either return video bytes or promptly report a malformed response. flowchart LR
A[Video task completes] --> B[Provider downloads media URL]
B --> C[Debug capture clones response]
C --> D[Provider validates media type]
D -->|Malformed| E[Start body cancellation]
E --> F[Return malformed-video error]
D -->|Valid video| G[Read and return video]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +4, Tests +108. Total +112 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Land the focused provider-owned cancellation change after normal exact-head merge and check gates; keep any broader capture-read timeout work separate from this visible-error repair. Do we have a high-confidence way to reproduce the issue? Yes. The supplied real-runtime harness uses the actual provider entry points, patched global fetch, and a real never-ending loopback response; its reverted awaited-cancel arm matches the unchanged current-main lines. Is this the best way to solve the issue? Yes. The provider-owned fire-and-forget cancellation is the narrowest fix for the visible hang and matches current OpenAI video and other tee-safe provider paths. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 50a30b7373d7. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
Punchcard-Session: crisp-lantern-orchard-nv * origin/main: perf(memory): defer session backfill runtime (#119372) fix(ci): isolate built TUI PTY fixture (#119339) fix(commands): restore tool inventory for dynamic models (#119306) fix(media): release rejected BytePlus and Runway video downloads under debug capture (#119257) docs: add ChromeOS (Crostini) platform install guide (#107663) test(msteams): serve JWKS from in-process server in auth coverage (#119354) fix(qa): enable OpenAI for stored audio scenario (#119349) test(agents): realpath apply-patch temp dir fixture (#119353) test(slack): drop redundant .js-suffixed system-event mock (#119352) fix(exec): leave safe builtins unrewritten in enforced mode (#119351) fix(sessions): keep gateway responsive while large transcript archives are built (#112424) fix(tui): restore provider auth in installed local mode (#119283)
…time * origin/main: (75 commits) fix(commands): restore tool inventory for dynamic models (#119306) fix(media): release rejected BytePlus and Runway video downloads under debug capture (#119257) docs: add ChromeOS (Crostini) platform install guide (#107663) test(msteams): serve JWKS from in-process server in auth coverage (#119354) fix(qa): enable OpenAI for stored audio scenario (#119349) test(agents): realpath apply-patch temp dir fixture (#119353) test(slack): drop redundant .js-suffixed system-event mock (#119352) fix(exec): leave safe builtins unrewritten in enforced mode (#119351) fix(sessions): keep gateway responsive while large transcript archives are built (#112424) fix(tui): restore provider auth in installed local mode (#119283) fix(release): accept legacy empty core artifacts (#119337) fix(qa): carry selected runtime into flow scenarios (#119324) fix(ci): retry interrupted Windows dashboard release checks (#119095) fix(release): filter validation ancestry fetch (#119334) fix(release): accept trusted extended-stable validation evidence (#119264) fix(sessions): preserve recorder-owned user turns (#119307) perf(cli): split plugin registry startup timing (#119318) fix(qa): align release scenario setup and compaction proof (#119188) fix(ci): avoid duplicate Matrix release QA runs (#119171) perf(agents): reuse provider policy manifest registry (#119305) ...
…r debug capture (openclaw#119257) …r debug capture When the debug proxy is enabled it patches global fetch and clones every response, so the caller-facing body is one branch of a live tee. Cancelling such a branch settles only after both branches cancel, so awaiting it in the rejected-download path leaves the download pending instead of surfacing the malformed-response error. Both providers read the completed media URL through the global fetch, so they reach the capture clone. Switch them to the fire-and-forget release the other generated-media owners already use, and cover each with a regression that keeps a capture clone live while the download is rejected. Co-authored-by: Tak Hoffman <[email protected]>
What Problem This Solves
Fixes an issue where users generating video with BytePlus or Runway while the debug proxy is enabled would see the generation hang instead of failing, when the provider returns a successful HTTP 200 whose body is not video (a JSON error page, an HTML sign-in page) and that body does not finish arriving.
The download never returns, so the request sits pending until the surrounding timeout fires, and the user never sees the
malformed video responseerror the provider already knows how to raise.Why This Change Was Made
OPENCLAW_DEBUG_PROXY_ENABLEDinstalls a global-fetch patch that clones every captured response (src/proxy-capture/runtime.ts:292-320,:51). A clone tees the body, and the repo already documents the consequence atsrc/proxy-capture/runtime.ts:41-46:Both providers resolve their download
fetchFnto the globalfetch(extensions/byteplus/video-generation-provider.ts:281,extensions/runway/video-generation-provider.ts:394), so under capture the response they hold is exactly such a branch — and bothawaitits cancellation when the binary check rejects. The capture branch is read concurrently andcaptureHttpExchangeis not awaited, so while that read is still in flight nothing releases the awaited cancel.This switches the two rejected-download paths to the fire-and-forget release used by the other generated-media owners, matching the decision already merged for the Ollama setup path in #111802 (
extensions/ollama/src/setup.ts:147). Scope is deliberately limited to these two call sites; the surrounding validation, error wording, and byte caps are untouched.User Impact
With the debug proxy on, a malformed BytePlus or Runway video download now fails immediately with the existing
... generated video download: malformed video responseerror instead of hanging until a timeout. With the proxy off, behavior is unchanged — the socket is still released, just without waiting on it.Evidence
The mechanism, measured with a control arm (
node v22.20.0, plain web streams):Only the teed-with-live-sibling arm fails to settle, which is the shape the capture clone produces.
Regression tests. One per provider, each building a real
Response, cloning it as the debug proxy does, leaving the capture branch mid-read, then racing the download against a 500 ms deadline:Mutation control. Reverting only the two production lines and re-running the same suites fails exactly the two new tests and nothing else, at the deadline rather than on the assertion:
The pre-existing
cancels the unread response body when a generated-video MIME type is rejectedtests pass either way — their stubbedcancelresolves immediately, so they cannot see this — which is why the new coverage builds a real tee.Gates.
oxfmt --checkclean on the four files,oxlintclean on both extensions,check-max-lines-ratchetOK, andtsgo --noEmitreports nothing in these files.Real-runtime proof: shipped capture patch, real socket
Added after review. Harness on
node v24.15.0that runs the real provider entry point(
buildBytePlusVideoGenerationProvider().generateVideo/ the Runway equivalent) through thereal capture patch:
initializeDebugProxyCapture()installs the shipped global-fetch patch;isDebugProxyGlobalFetchPatchInstalled()is assertedtruebefore the run.node:httploopback origin serves the generated-media URL: HTTP 200,content-type: application/json, one chunk written and the body never ended.response the provider holds is a live capture-clone tee branch, not a modeled one.
paid account. It sits below the capture patch, so the download path is untouched. The SSRF
guard dials undici directly when the caller fetch is identity-equal to
globalThis.fetch(
src/infra/net/fetch-guard.ts:645-658), so the harness re-wraps the patched chain under afresh identity; that affects only the two task-API calls.
After fix, BytePlus:
After fix, Runway:
Same harness, reverting only the two production lines to
await response.body?.cancel():The full matrix isolates debug capture as the cause rather than the loopback origin or the
never-ending body:
await(before this PR)void(this PR)malformed video responseafter 14 msawait(before this PR)malformed video responseafter 64 msvoid(this PR)malformed video responseafter 15 msawait(before this PR)void(this PR)malformed video responseafter 14 msThe hang appears only in the capture-on,
awaitcell, which is the cell this PR removes.