Skip to content

fix(video-generation): DashScope downloads hang when CDN body stalls after headers - #109394

Merged
steipete merged 7 commits into
openclaw:mainfrom
Pick-cat:fix/dashscope-video-download-idle
Jul 17, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
Pick-cat:fix/dashscope-video-download-idle

Conversation

@Pick-cat

@Pick-cat Pick-cat commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes two issues with DashScope-compatible video downloads:

  1. Stalled CDN body hang: After headers returned, no chunk-idle timeout was wired into readResponseWithLimit, so a stalled body could wait the full request budget instead of failing with a clear idle timeout.
  2. Exhausted deadline initiates network I/O: A function-valued remaining deadline that returned 0 (budget consumed by header fetch) was checked AFTER fetchWithTimeoutGuarded had already sent bytes over the wire. The guard now runs before fetch.

Affected workflow: runDashscopeVideoGenerationTask → downloadDashscopeGeneratedVideos → readResponseWithLimit.

Why This Change Was Made

At downloadDashscopeGeneratedVideos, the resolved downloadTimeoutMs is now:

  • Checked before fetch: a non-positive remaining budget throws immediately without network I/O, matching the sibling Google video download path's behavior.
  • Passed as chunkTimeoutMs + onIdleTimeout into readResponseWithLimit, so stalled bodies fail with "no data received for <timeout>ms" instead of a generic fetchWithTimeoutGuarded deadline.

fetchWithTimeoutGuarded already keeps its abort until release(), so a continuously dripping CDN body cannot hang forever; the chunk-idle bound is the download-owned stall signal that was missing.

Non-goals: changing shared fetchWithTimeoutGuarded, readResponseWithLimit, or assertOkOrThrowHttpError.

Collision check: no open PR on downloadDashscopeGeneratedVideos / src/video-generation/dashscope-compatible.ts.

User Impact

  • Stalled DashScope video downloads fail with "no data received for <timeout>ms" instead of a generic request timeout or full-budget wait.
  • Already-exhausted remaining budgets fail immediately without network I/O.
  • Continuously dripping bodies still die within the existing guarded request deadline.

Evidence

Exact head: 920b47be7e9a11c1fbb78845226d51aca97afdf8

oxfmt --check src/video-generation/dashscope-compatible.ts src/video-generation/dashscope-compatible.test.ts — passed.
git diff --check — clean.

Tests

node scripts/run-vitest.mjs src/video-generation/dashscope-compatible.test.ts -- --run --reporter=verbose
 ✓ aborts a stalled generated video body via chunk idle timeout 511ms
 ✓ persists a complete generated video body before the idle deadline 5ms
 ✓ fails closed before fetch when a function-valued remaining budget is exhausted 5ms
 ✓ bounds a stalled loopback HTTP body with a real server 220ms

 Test Files  1 passed (1)
      Tests  4 passed (4)

Key contract changes

Before After
Exhausted deadline checked after fetchWithTimeoutGuarded (network I/O already initiated) Checked before fetch — throws immediately, fetchFn not called
Body had no chunk-idle timeout → stalled bodies hit generic request timeout chunkTimeoutMs + onIdleTimeout wired → "no data received for <timeout>ms"

Loopback proof

Real http.createServer returns HTTP 200 + one chunk then stalls. Real fetch + real downloadDashscopeGeneratedVideos with timeoutMs: 200 rejects within 5s (~220ms observed) — bounded, not an indefinite hang.

Not tested

Live DashScope CDN against real provider endpoints — requires real API credentials.

@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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 1:50 AM ET / 05:50 UTC.

Summary
The PR adds fail-fast exhausted-budget handling, response-body idle timeouts, guarded-fetch cleanup, and focused regression coverage for DashScope-compatible generated-video downloads.

PR surface: Source +40, Tests +143. Total +183 across 2 files.

Reproducibility: yes. at source level with high confidence: current main omits a body-idle timeout, and the real loopback server exercises the same post-header stalled-body path, although no live credentialed DashScope CDN run was supplied.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦀 challenger crab
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Next step before merge

  • No automated repair remains; the assigned maintainer can complete exact-head check and merge validation.

Security
Cleared: The diff adds no dependency, workflow, credential, permission, package-resolution, or new network-authority surface, and the guarded resource cleanup is strengthened.

Review details

Best possible solution:

Keep the timeout policy in the DashScope download owner while reusing the shared guarded-fetch and bounded-stream primitives, then land the exact head after its required checks complete.

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

Yes at source level with high confidence: current main omits a body-idle timeout, and the real loopback server exercises the same post-header stalled-body path, although no live credentialed DashScope CDN run was supplied.

Is this the best way to solve the issue?

Yes. The narrow owner-local change reuses existing timeout and bounded-read contracts, matches the sibling fail-before-fetch principle, and avoids broad changes to shared networking helpers that serve different retry and timeout policies.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: A stalled generated-video response can hold a real provider workflow until the long operation deadline, and this focused fix restores bounded failure behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦀 challenger crab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): A real loopback HTTP server, real fetch, and the production download function demonstrate the after-fix stalled-body rejection; the contributor should continue redacting any private provider details if live evidence is later added.
  • proof: sufficient: Contributor real behavior proof is sufficient. A real loopback HTTP server, real fetch, and the production download function demonstrate the after-fix stalled-body rejection; the contributor should continue redacting any private provider details if live evidence is later added.
Evidence reviewed

PR surface:

Source +40, Tests +143. Total +183 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 43 3 +40
Tests 1 143 0 +143
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 186 3 +183

What I checked:

  • Current-main behavior: The current implementation passes the operation timeout to the guarded download fetch but reads the response body with only a byte limit, so no download-owned chunk-idle timeout covers a body that stalls after headers. (src/video-generation/dashscope-compatible.ts:361, 5e13f459a7d5)
  • Latest-head fix: The PR resolves and validates the remaining download budget before fetch, re-resolves it for the body stage, supplies chunkTimeoutMs and a provider-specific idle error, and releases the guarded request after success or failure. (src/video-generation/dashscope-compatible.ts:379, 2134cd67c569)
  • Regression coverage: The added tests cover a stalled mocked body, successful completion before the idle deadline, exhausted-budget rejection before fetch, and a real loopback HTTP server that sends headers and one chunk before stalling. (src/video-generation/dashscope-compatible.test.ts:1, 2134cd67c569)
  • Real behavior proof: The contributor reports the production download function with real fetch against a real loopback HTTP server rejecting the stalled body at about 220 ms for a 200 ms budget; live DashScope credentials were not required to exercise the transport failure shape. (src/video-generation/dashscope-compatible.test.ts:104, 2134cd67c569)
  • Review continuity: Earlier exhausted-budget findings were addressed before head 920b47be7e9ef51620386b8de18727e257719380, and the latest maintainer-authored follow-up adds cleanup for failed guarded downloads rather than reopening those findings. (src/video-generation/dashscope-compatible.ts:379, 2134cd67c569)
  • Sibling ownership boundary: The related music-generation PR handles a distinct owner surface with wall-clock drip and retry semantics; this PR appropriately keeps the DashScope-specific repair local while reusing shared fetch and bounded-read primitives. (src/video-generation/dashscope-compatible.ts:343, 2134cd67c569)

Likely related people:

  • steipete: Assigned the PR and authored the latest guarded-download cleanup commit on the affected runtime path. (role: recent area contributor; confidence: high; commits: 2134cd67c569; files: src/video-generation/dashscope-compatible.ts)
  • vincentkoc: The video-generation capability and its provider runtime appear to date to the mode-aware video-generation work, making this contributor relevant for shared behavior and ownership questions. (role: feature introducer; confidence: medium; commits: 6b53a9aadb; files: src/video-generation/dashscope-compatible.ts, src/video-generation/types.ts)
  • wangmiao0668000666: Recently hardened the same DashScope-compatible module's submit and poll response reads through merged pull request fix(video-generation): bound dashscope JSON response reads at 16 MiB #96782. (role: recent adjacent contributor; confidence: medium; commits: 238398e33147; files: src/video-generation/dashscope-compatible.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 (5 earlier review cycles)
  • reviewed 2026-07-16T23:55:50.101Z sha a65c45eda5130837cf8e659258c626e7b3a2e7e8 :: needs real behavior proof before merge. :: [P1] Preserve an exhausted operation deadline
  • reviewed 2026-07-17T02:57:27.714Z sha 456184f3a3c2d06560908cbe63f3220ec1bc183d :: needs changes before merge. :: [P1] Reject the exhausted budget before starting the fetch
  • reviewed 2026-07-17T03:49:08.892Z sha 456184f3a3c2d06560908cbe63f3220ec1bc183d :: needs changes before merge. :: [P1] Reject an exhausted deadline before starting fetch
  • reviewed 2026-07-17T04:18:06.522Z sha 920b47be7e9ef51620386b8de18727e257719380 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T05:00:44.517Z sha 920b47be7e9ef51620386b8de18727e257719380 :: needs maintainer review before merge. :: none

@Pick-cat
Pick-cat force-pushed the fix/dashscope-video-download-idle branch from a65c45e to 456184f Compare July 17, 2026 02:08
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 17, 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.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 17, 2026
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Jul 17, 2026
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 17, 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.

Re-review progress:

@clawsweeper clawsweeper Bot added 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 17, 2026
@steipete steipete self-assigned this Jul 17, 2026
Pick-cat and others added 3 commits July 17, 2026 06:28
…dget

When the operation deadline passes a function that returns 0, the
previous resolver gate (resolved > 0) dropped the exhausted budget
and fell back to the 120s default. Also, readResponseWithLimit skips
chunk idle timeout when chunkTimeoutMs is 0/falsy, so a zero budget
would read the body unbounded instead of failing fast.

Now the resolver preserves zero/negative values and the body stage
throws immediately when the remaining budget is exhausted.

Co-Authored-By: nebulacoder-v8.0 <[email protected]>
Check the resolved download timeout before fetchWithTimeoutGuarded so an
already-exhausted operation does not initiate network I/O. Previously the
deadline guard ran after headers, which still sent bytes over the wire.

Co-Authored-By: nebulacoder-v8.0 <[email protected]>
@steipete
steipete force-pushed the fix/dashscope-video-download-idle branch from 920b47b to 2134cd6 Compare July 17, 2026 05:45
@steipete

Copy link
Copy Markdown
Contributor

Maintainer verification on exact head 2134cd67c569d3e79e82513aa6b3f43d817e705f:

  • Deep-reviewed the whole DashScope-compatible task module, shared task-deadline resolver, guarded-fetch release contract, bounded body reader, retry boundary, Google sibling downloader, callers, and adjacent tests.
  • Rebased onto current main and kept the change as a pure bug fix: no UI, config, environment variable, parameter, or capability addition.
  • Moved the post-header deadline resolution under release() protection. When it throws or is exhausted, the unread body is now canceled before release clears the guarded abort timer.
  • Removed the false claim that guarded fetch clears its timeout at headers. The shared guard keeps that timeout active until release.
  • Deleted the 51-line loopback test that accepted any rejection. Replaced it with a deterministic regression proving resolver failure cancels the body and clears the guard timer.
  • node scripts/run-vitest.mjs src/video-generation/dashscope-compatible.test.ts passed through three repair iterations; final 4/4.
  • node scripts/check-changed.mjs -- src/video-generation/dashscope-compatible.ts src/video-generation/dashscope-compatible.test.ts passed all delegated core gates, including formatting, SDK baseline, boundaries, core/test typechecks, lint, database/media/import/webhook/pairing guards. Testbox: https://github.com/openclaw/openclaw/actions/runs/29557591428
  • Fresh autoreview found a real unread-body cleanup gap; fixed it. Rerun clean.
  • Official Alibaba Wan docs confirm successful tasks return a signed video_url for prompt download: https://www.alibabacloud.com/help/en/model-studio/image-to-video-general-api-reference

Verdict: best owner-side fix. Awaiting exact-head CI before /prepare-pr.

@steipete
steipete merged commit f4f5150 into openclaw:main Jul 17, 2026
116 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…after headers (openclaw#109394)

* fix(video-generation): bound stalled DashScope download body reads

* test(video-generation): narrow DashScope download asset for tsgo

* test(video-generation): narrow optional DashScope video buffer for tsgo

* test(video-generation): bind DashScope buffer before tsgo asserts

* fix(video-generation): fail closed on exhausted DashScope download budget

When the operation deadline passes a function that returns 0, the
previous resolver gate (resolved > 0) dropped the exhausted budget
and fell back to the 120s default. Also, readResponseWithLimit skips
chunk idle timeout when chunkTimeoutMs is 0/falsy, so a zero budget
would read the body unbounded instead of failing fast.

Now the resolver preserves zero/negative values and the body stage
throws immediately when the remaining budget is exhausted.

Co-Authored-By: nebulacoder-v8.0 <[email protected]>

* fix(video-generation): reject exhausted download deadline before fetch

Check the resolved download timeout before fetchWithTimeoutGuarded so an
already-exhausted operation does not initiate network I/O. Previously the
deadline guard ran after headers, which still sent bytes over the wire.

Co-Authored-By: nebulacoder-v8.0 <[email protected]>

* fix(video-generation): release failed DashScope downloads

---------

Co-authored-by: nebulacoder-v8.0 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…after headers (openclaw#109394)

* fix(video-generation): bound stalled DashScope download body reads

* test(video-generation): narrow DashScope download asset for tsgo

* test(video-generation): narrow optional DashScope video buffer for tsgo

* test(video-generation): bind DashScope buffer before tsgo asserts

* fix(video-generation): fail closed on exhausted DashScope download budget

When the operation deadline passes a function that returns 0, the
previous resolver gate (resolved > 0) dropped the exhausted budget
and fell back to the 120s default. Also, readResponseWithLimit skips
chunk idle timeout when chunkTimeoutMs is 0/falsy, so a zero budget
would read the body unbounded instead of failing fast.

Now the resolver preserves zero/negative values and the body stage
throws immediately when the remaining budget is exhausted.

Co-Authored-By: nebulacoder-v8.0 <[email protected]>

* fix(video-generation): reject exhausted download deadline before fetch

Check the resolved download timeout before fetchWithTimeoutGuarded so an
already-exhausted operation does not initiate network I/O. Previously the
deadline guard ran after headers, which still sent bytes over the wire.

Co-Authored-By: nebulacoder-v8.0 <[email protected]>

* fix(video-generation): release failed DashScope downloads

---------

Co-authored-by: nebulacoder-v8.0 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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