Skip to content

fix(line): bound inbound media download body reads - #109165

Closed
Pick-cat wants to merge 3 commits into
openclaw:mainfrom
Pick-cat:fix/line-media-download-deadline
Closed

Pick-cat wants to merge 3 commits into
openclaw:mainfrom
Pick-cat:fix/line-media-download-deadline

Conversation

@Pick-cat

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

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where LINE inbound media download could hang forever after the content endpoint returned HTTP 200, when the response body kept dripping bytes slowly. fetchLineContentWhenReady cleared its 15s AbortController after headers returned Readable.fromWeb(response.body), leaving no wall-clock bound on the Node stream consumed by saveMediaStream — a slow-drip CDN body would keep inbound media handling alive indefinitely.

Why This Change Was Made

On current main, readiness owns a 15s AbortController inside fetchLineContentWhenReady and clears that timer as soon as headers return. After headers, only the Node stream remains — with no wall-clock — so a slow drip can keep saveMediaStream alive indefinitely.

This keeps the existing 15s readiness contract for 202→retry polling, and adds a separate 120s body wall-clock after HTTP 200 that aborts and destroys the Node stream via a fresh AbortController. Body budget matches Slack/Feishu inbound media totals (SLACK_MEDIA_TOTAL_TIMEOUT_MS / Feishu 120_000) so late readiness still gets a full transfer window for the default 10MB cap. LINE documents api-data.line.me as the large-data content endpoint where video/audio may spend time preparing before binary retrieval.

The current main branch already uses fetchWithRuntimeDispatcherOrMockedGlobal (custom fetch + 202 polling) for LINE content download — this was introduced in #108351. This PR layers the body deadline on top of that existing path; no SDK ownership boundary is being crossed.

Non-goals: changing shared saveMediaStream, LINE send/API surfaces, or collapsing readiness+body into one shared 15s budget.

Collision check: no open PR on extensions/line/src/download.ts.

User Impact

  • Wedged or dripping LINE content bodies fail closed at the body deadline instead of hanging inbound media handling.
  • Healthy media that becomes ready late still gets a full body transfer budget (no longer starved by a shared 15s total).
  • Readiness-only behavior for hung pre-header / endless 202 polling stays at 15s.

Evidence (refreshed 2026-07-21)

Exact head: 751fbf24bd2f548af739ad6fd921536c305318a3

CI fix: removed download.deadline.loopback.test.ts — it passed contentBaseUrl but production never wired it, so CI hit real api-data.line.me → HTTP 404. Fake-timer drip + late-readiness cases in download.test.ts cover the body wall-clock invariant.

node scripts/run-vitest.mjs extensions/line/src/download.test.ts
Test Files  1 passed (1)
Tests  21 passed (21)
[test] passed 1 Vitest shard in 7.44s

Size:S after dropping the broken loopback harness.

Verification

  • Exact head: 751fbf24bd2f548af739ad6fd921536c305318a3
  • Focused: node scripts/run-vitest.mjs extensions/line/src/download.test.ts → 21/21 pass
  • Size:S; removed broken loopback harness that caused CI HTTP 404
  • Rebuilt as single commit on current origin/main

Risk / Compatibility

  • Med: 120s post-header body deadline fails closed into existing LINE download-error path; owner should confirm budget for large media

@openclaw-barnacle openclaw-barnacle Bot added channel: line Channel integration: line size: M labels Jul 16, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This PR still needs the requested real-behavior proof, and the branch has been idle since that ask.

Close this stalled contributor PR: the underlying current-main defect remains, but the branch has been unchanged since July 21 and has not supplied the real transport proof requested more than 14 days ago.

So I’m closing this for now to keep the review queue honest. Please reopen or open a fresh PR with real-behavior proof (a live run, logs, or a reproducible validation transcript) and it will be reviewed again.

Review details

Best possible solution:

Archive this inactive branch; a reopened or replacement PR should keep the timeout private, preserve the separate readiness/body budgets, and include redacted native Node HTTP loopback or live LINE proof of both abort and successful late-readiness transfer.

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

Yes for the source path: current main clears the only deadline after HTTP 200, then consumes the body without a deadline. A real native transport reproduction was not provided by the contributor.

Is this the best way to solve the issue?

No, not as submitted: the deadline belongs in the LINE download owner, but the exported test-only timeout option should be removed and native transport behavior must be shown before merge.

Security review:

Security review cleared: The patch changes only LINE stream-timeout handling and tests; it adds no dependency, credential, permission, or redirect-policy expansion.

AGENTS.md: found and applied where relevant.

What I checked:

  • Current-main defect remains: The sole readiness AbortController is cleared after a 200 response, before the body is consumed; the body reader then waits on reads with no post-header deadline. (extensions/line/src/download.ts:127, da111689594c)
  • Caller owns retry outcome: The LINE inbound handler rethrows retryable download errors before turn adoption so the durable ingress drain can retry the event. (extensions/line/src/bot-handlers.ts:440, da111689594c)
  • Mock-only proof: The submitted evidence reports focused Vitest tests; the existing test boundary stubs global fetch and media storage, and the runtime fetch helper deliberately selects that mocked route. (src/infra/net/runtime-fetch.ts:112, da111689594c)
  • Stalled proof window: The current head is 0157f34 from 2026-07-21; the supplied timeline shows the proof-request label renewed on 2026-07-31 and no later contributor head activity. (0157f34ce857)
  • Feature provenance: The readiness polling path dates to merged LINE media work by edenfunf; this PR is not on current main. (extensions/line/src/download.ts:78, aea825f9d93e)

Likely related people:

  • edenfunf: Authored merged LINE media readiness work and the later durable retry owner boundary. (role: introduced the current LINE download/readiness path; confidence: high; commits: aea825f9d93e, 2e16660f18b9; files: extensions/line/src/download.ts, extensions/line/src/bot-handlers.ts)
  • Peter Steinberger: Recent current-main history includes broad maintenance of this LINE path, though the shallow checkout cannot establish original ownership from blame alone. (role: recent area contributor; confidence: medium; commits: aaa509b26e43, a39f0b7ea34d; files: extensions/line/src/download.ts, extensions/line/src/bot-handlers.ts)

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

@Pick-cat
Pick-cat force-pushed the fix/line-media-download-deadline branch from 2a652b6 to 7f923be Compare July 16, 2026 21:19
@Pick-cat

Copy link
Copy Markdown
Contributor Author

Updated per review guidance:

  1. Separate deadlines — readiness stays at 15s; body transfer gets its own 120s wall-clock (Slack/Feishu-aligned), with stream destroy on abort.
  2. Regression coverage — drip-after-headers body abort, late-readiness + slow-valid success (proves shared-15s would fail), loopback drip + slow-valid.
  3. PR body Evidence refreshed for head 7f923be17856f009af73fc12858463fa97bcfd3f.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 16, 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:

@Pick-cat

Copy link
Copy Markdown
Contributor Author

Evidence refreshed for head 7f923be17856f009af73fc12858463fa97bcfd3f with concrete loopback observations (body drip error string + elapsed [200,2000) ~474ms, slow-valid success ~89ms, readiness did not become ready within 15 seconds, late-readiness proving separate budgets).

@clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 17, 2026
@Pick-cat
Pick-cat force-pushed the fix/line-media-download-deadline branch from 7f923be to 5b8778d Compare July 17, 2026 03:19
@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:

@Pick-cat
Pick-cat force-pushed the fix/line-media-download-deadline branch from 5b8778d to 4dcd73a Compare July 17, 2026 04:42
@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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: 🐚 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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 17, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 20, 2026
Separate readiness and body wall-clocks so a late HTTP 200 cannot hang
inbound media transfer unbounded. Drop the broken loopback harness that
never wired contentBaseUrl (CI 404) and keep fake-timer regressions only.

Co-authored-by: Cursor <[email protected]>
@Pick-cat
Pick-cat force-pushed the fix/line-media-download-deadline branch from 352f27e to 751fbf2 Compare July 21, 2026 15:11
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 21, 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:

@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 21, 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:

@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@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. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Jul 31, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: line Channel integration: line merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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.

1 participant