Skip to content

fix(tlon): bound stalled inbound and outbound media header waits - #104132

Merged
steipete merged 2 commits into
openclaw:mainfrom
chengzhichao-xydt:fix/tlon-media-header-timeout
Jul 13, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
chengzhichao-xydt:fix/tlon-media-header-timeout

Conversation

@chengzhichao-xydt

@chengzhichao-xydt chengzhichao-xydt commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Tlon inbound downloadMedia and outbound uploadImageFromUrl call readRemoteMediaBuffer / saveRemoteMedia with only a 30-second body-idle timeout. If the remote server never returns response headers, the idle timeout never starts and the request can hang indefinitely. This is the same root cause as the Telegram media stall fixed in #103020.

Why This Change Was Made

Add a 120-second response-header deadline (responseHeaderTimeoutMs) to both call sites, mirroring the Telegram media timeout policy, so stalled endpoints fail fast without cutting off healthy long transfers.

User Impact

Tlon media downloads and image uploads time out predictably when a server never sends headers, instead of blocking the channel.

Evidence

Unit tests

pnpm test extensions/tlon/src/monitor/media.test.ts extensions/tlon/src/urbit/upload.test.ts --run

Result: 2 files, 11 tests passed.

Type / lint

pnpm tsgo:extensions   # exit 0
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/tlon/src/monitor/media.ts extensions/tlon/src/monitor/media.test.ts extensions/tlon/src/urbit/upload.ts extensions/tlon/src/urbit/upload.test.ts

Both pass.

Controlled real-runtime proof

A local HTTP server was used: one endpoint returns a small PNG immediately; another endpoint accepts the connection but never sends response headers. The shared media runtime was exercised with the same options this PR now passes from Tlon (responseHeaderTimeoutMs: 120_000, readIdleTimeoutMs: 30_000). SSRF was relaxed to dangerouslyAllowPrivateNetwork only for the loopback test server.

=== Tlon media header-timeout proof ===
Server listening on http://127.0.0.1:46183
Configured responseHeaderTimeoutMs: 120000

[outbound-healthy] ok: contentType=image/png, bytes=13
[inbound-healthy] ok: path=/home/.../.openclaw/media/inbound/e4e4eac5-edab-4834-9859-cba85a575db2.png, contentType=image/png, size=13

Starting parallel stalled-header fetches (will take ~120s each)...
[fetch-timeout] fetch timeout after 120000ms (elapsed 120000ms) operation=media response headers url=http://127.0.0.1:46183/stall
[fetch-timeout] fetch timeout after 120000ms (elapsed 120060ms) operation=media response headers url=http://127.0.0.1:46183/stall
[outbound-stall] rejected after 120076ms: Failed to fetch media from http://127.0.0.1:46183/stall: request timed out
[inbound-stall] rejected after 120076ms: Failed to fetch media from http://127.0.0.1:46183/stall: request timed out

Healthy transfers complete; stalled headers abort near the 120-second deadline. In the Tlon channel code the resulting rejection is caught and the message continues without the failed attachment (inbound) or falls back to the original image URL (outbound).

Release Note

  • Tlon: bound stalled inbound/outbound media header waits.

@openclaw-barnacle openclaw-barnacle Bot added channel: tlon Channel integration: tlon size: XS labels Jul 11, 2026
@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. P2 Normal backlog priority with limited blast radius. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 12, 2026, 8:27 PM ET / July 13, 2026, 00:27 UTC.

Summary
The PR centralizes a 120-second Tlon response-header deadline and the existing 30-second body-idle deadline, then applies that policy to inbound media downloads and outbound URL-backed image uploads with matching assertions.

PR surface: Source +5, Tests +2. Total +7 across 5 files.

Reproducibility: yes. at source level: on current main, a server that accepts the connection but never returns headers leaves both Tlon calls waiting because only the post-header body-idle timer is configured. The controlled runtime transcript demonstrates the proposed header deadline firing on both paths.

Review metrics: none identified.

Root-cause cluster
Relationship: canonical
Canonical: #104132
Summary: This PR is the current viable Tlon fix for stalled response-header waits; earlier Tlon proposals are closed and used broader or differently calibrated timeout shapes.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Risk before merge

  • [P1] Existing Tlon endpoints that legitimately take longer than 120 seconds to return response headers will now drop the inbound attachment or use the original outbound image URL; this is a deliberate compatibility boundary rather than a correctness defect.

Maintainer options:

  1. Land the calibrated timeout policy (recommended)
    Accept the maintainer-refactored 120-second header boundary and merge after the current head's required checks complete successfully.
  2. Retune the Tlon boundary
    Change the shared constant before merge only if Tlon owners have evidence that valid endpoints routinely need more than 120 seconds to return headers.

Next step before merge

  • No automated repair is needed; normal exact-head checks and maintainer merge review are the remaining steps.

Security
Cleared: The patch adds no dependency or execution surface and preserves the shared SSRF, redirect, byte-limit, and guarded-fetch behavior while only bounding header wait duration.

Review details

Best possible solution:

Land the shared header-only timeout policy once exact-head checks are green, preserving the 30-second body-idle limit and existing inbound omission and outbound original-URL fallbacks.

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

Yes at source level: on current main, a server that accepts the connection but never returns headers leaves both Tlon calls waiting because only the post-header body-idle timer is configured. The controlled runtime transcript demonstrates the proposed header deadline firing on both paths.

Is this the best way to solve the issue?

Yes. Reusing the shared header-only timeout contract at the Tlon owner boundary is narrower than a whole-request timeout, avoids capping healthy progressive bodies, and one shared local policy prevents inbound and outbound drift.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: The PR fixes a real channel-specific indefinite media wait with meaningful but bounded Tlon impact.
  • merge-risk: 🚨 compatibility: Merging introduces a new 120-second cutoff for existing Tlon servers that previously had no response-header deadline.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix live output from a controlled HTTP server showing healthy inbound and outbound fetches succeed and withheld-header requests reject near the configured 120-second deadline.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix live output from a controlled HTTP server showing healthy inbound and outbound fetches succeed and withheld-header requests reject near the configured 120-second deadline.
Evidence reviewed

PR surface:

Source +5, Tests +2. Total +7 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 10 5 +5
Tests 2 2 0 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 12 5 +7

What I checked:

  • Current-main inbound gap: At current main, Tlon inbound media passes only readIdleTimeoutMs: 30_000; a server that never returns headers therefore never starts that idle timer. (extensions/tlon/src/monitor/media.ts:70, 55067fd5e7be)
  • Current-main outbound gap: The outbound URL-backed upload path likewise passes only the 30-second body-idle timeout and falls back to the original URL when fetching fails. (extensions/tlon/src/urbit/upload.ts:23, 55067fd5e7be)
  • Canonical timeout contract: The shared media runtime separately supports response-header and body-idle deadlines, clearing the header timer after headers arrive so healthy progressive bodies are not capped. (src/media/fetch.ts:82, 55067fd5e7be)
  • Fallback behavior remains intact: Inbound processing catches download failures and omits the failed attachment, while outbound upload fetching retains its original-URL fallback; the patch bounds waiting without changing those established outcomes. (extensions/tlon/src/monitor/media.ts:85, 55067fd5e7be)
  • Regression assertions: The adjacent tests assert the complete option bags for both calls; the PR adds the 120-second header deadline while retaining the 30-second idle deadline. (extensions/tlon/src/monitor/media.test.ts:55, c40f08bbe378)
  • Real behavior proof: The PR body records healthy inbound and outbound transfers succeeding and two withheld-header requests rejecting near 120 seconds through the same shared runtime options now passed by Tlon; the repository proof check also succeeded. (c40f08bbe378)

Likely related people:

  • steipete: He merged the shared media response-header timeout implementation and authored the current PR head's Tlon policy-sharing refactor, connecting him to both the contract and selected 120-second boundary. (role: recent feature contributor and merger; confidence: high; commits: 26aef8c48bc4, c40f08bbe378; files: src/media/fetch.ts, extensions/tlon/src/media-fetch-timeouts.ts, extensions/tlon/src/monitor/media.ts)
  • Alix-007: Their merged Telegram work introduced and proved the canonical responseHeaderTimeoutMs behavior that this Tlon patch reuses. (role: shared timeout feature introducer; confidence: medium; commits: 819c9d65333c; files: src/media/fetch.ts, src/media/fetch.test.ts, extensions/telegram/src/bot/delivery.resolve-media-retry.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 (4 earlier review cycles)
  • reviewed 2026-07-11T03:51:49.931Z sha ccddafdb08cfd8bf571882a56778021c12af38ff :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T05:04:58.611Z sha 68329bcd543e30a1f81544752231f11ac5f52cfa :: needs maintainer review before merge. :: none
  • reviewed 2026-07-11T06:10:56.504Z sha 68329bcd543e30a1f81544752231f11ac5f52cfa :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T00:17:38.794Z sha 847ce3ebb9cb7d8f31fa9874db05532e98212ab5 :: needs maintainer review before merge. :: none

@chengzhichao-xydt
chengzhichao-xydt force-pushed the fix/tlon-media-header-timeout branch from ccddafd to 68329bc Compare July 11, 2026 04:53
@chengzhichao-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added controlled real-runtime proof for the Tlon media header timeout.

A local server was used: a healthy endpoint returns a small PNG; a stalled endpoint accepts the connection but never sends headers. The shared media runtime was exercised with the same options this PR adds to Tlon (responseHeaderTimeoutMs: 120_000, readIdleTimeoutMs: 30_000, SSRF relaxed only for the loopback test server).

Result:

  • Healthy inbound (saveRemoteMedia) and outbound (readRemoteMediaBuffer) fetches succeed.
  • Stalled-header fetches for both paths abort near 120s with fetch timeout after 120000ms ... operation=media response headers.

Verification:

  • pnpm test extensions/tlon/src/monitor/media.test.ts extensions/tlon/src/urbit/upload.test.ts --run — 11 passed
  • pnpm tsgo:extensions — exit 0
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/tlon/src/monitor/media.ts extensions/tlon/src/monitor/media.test.ts extensions/tlon/src/urbit/upload.ts extensions/tlon/src/urbit/upload.test.ts — exit 0

Full redacted output is included in the updated PR body.

@clawsweeper

clawsweeper Bot commented Jul 11, 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 the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 11, 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 11, 2026
@chengzhichao-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Fixed the rendered PR body — the previous update stored the file path literal by mistake. The body now contains the full context and the redacted controlled runtime proof showing healthy inbound/outbound fetches succeed and stalled-header fetches abort near the 120-second deadline.

Head SHA: 68329bcd54

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 11, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 13, 2026
@steipete
steipete force-pushed the fix/tlon-media-header-timeout branch from 847ce3e to c40f08b Compare July 13, 2026 00:23
@steipete

Copy link
Copy Markdown
Contributor

Maintainer closeout for #104132:

  • Reviewed the Tlon media fetch path across inbound monitor downloads and outbound Urbit uploads, plus the shared src/media/fetch.ts header/body timeout behavior.
  • Refactored the duplicated Tlon timeout literals into one TLON_MEDIA_FETCH_TIMEOUTS policy so inbound and outbound media stay aligned at responseHeaderTimeoutMs: 120_000 and readIdleTimeoutMs: 30_000.
  • Rebased the PR onto current main after the first exact-head CI run failed in check-guards with spawnSync git ENOBUFS while reading an oversized stale-base diff. The rebased PR delta is only the 5 Tlon files.
  • Testbox proof: tbx_01kxccj67y6ya2as05k223x7z3
    • corepack pnpm test extensions/tlon/src/monitor/media.test.ts extensions/tlon/src/urbit/upload.test.ts - 11 tests passed.
    • corepack pnpm test src/media/fetch.test.ts -t "response headers" - 4 focused tests passed.
    • corepack pnpm format:check -- extensions/tlon/src/media-fetch-timeouts.ts extensions/tlon/src/monitor/media.ts extensions/tlon/src/monitor/media.test.ts extensions/tlon/src/urbit/upload.ts extensions/tlon/src/urbit/upload.test.ts - passed.
    • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed - passed.
  • Fresh autoreview on the maintainer refactor was clean, correctness 0.99.
  • Exact-head CI is green for c40f08bbe37816c0ad5e6e0f2328431bf57c0b80: https://github.com/openclaw/openclaw/actions/runs/29215228260
  • Native scripts/pr prepare-run 104132 passed with hosted gates accepted.

Thanks @chengzhichao-xydt.

@steipete
steipete merged commit cacd435 into openclaw:main Jul 13, 2026
99 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

@steipete steipete mentioned this pull request Jul 13, 2026
3 tasks done
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 13, 2026
…nclaw#104132)

* fix(tlon): bound stalled inbound and outbound media header waits

* refactor(tlon): share media fetch timeout policy

---------

Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa pushed a commit that referenced this pull request Aug 30, 2026
…4132)

* fix(tlon): bound stalled inbound and outbound media header waits

* refactor(tlon): share media fetch timeout policy

---------

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit cacd435)
@chengzhichao-xydt
chengzhichao-xydt deleted the fix/tlon-media-header-timeout branch October 30, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: tlon Channel integration: tlon merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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