Skip to content

fix(line): stop inbound media hangs after response headers - #124606

Merged
steipete merged 1 commit into
mainfrom
fix/autoqa-plugin-response-deadline-v3
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/autoqa-plugin-response-deadline-v3

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: #109165

What Problem This Solves

Fixes an issue where a LINE inbound media message could leave delivery running indefinitely after LINE returned HTTP 200 headers but stalled the response body. Gateway shutdown also did not cancel that pre-adoption download, so old media work could continue after the durable ingress owner stopped.

Why This Change Was Made

The LINE download owner now keeps one existing 15-second absolute deadline across readiness polling, 202 backoff, response headers, and body EOF. It composes that deadline with the durable-ingress abort signal, preserves the exact winning abort reason, cancels and releases incomplete response readers, and rechecks ingress cancellation before accepting materialized media. Healthy 202-to-200 retry behavior, byte limits, MIME detection, persistence, and retry classification remain unchanged.

Maintainer decision: accept the 15-second total-transfer policy. A valid transfer that exceeds the single owner-held budget retries through durable ingress instead of holding that ingress claim indefinitely.

A separate post-header timeout was rejected because it would extend work beyond the existing deadline and lifecycle owner. Moving LINE policy into the shared media store was also rejected: the store already owns atomic sibling-temp cleanup, while LINE owns its API-specific readiness and retry contract.

User Impact

LINE media delivery now either finishes within the existing bounded window or rejects for durable retry; it no longer wedges indefinitely on a stalled body or continues after ingress shutdown. Text messages, outbound LINE sends, configuration, auth, routing, public plugin contracts, persistence schemas, release behavior, and deployment are unchanged.

Evidence

Exact reviewed candidate: 2dbf2e1bec02e824eb3d41aa16462f6b8e15c7bf. Rebased exact head: e0cd3b87953c650d7de6147d8de8e4236fc8acad on local origin/main eafeeec537a643d1f47459ec617516986b17c514. The rebase was conflict-free; all four before/after blob IDs and stable patch ID remained identical, so the accepted proof and autoreview still cover the exact change.

  • Controlled native loopback before fix: HTTP 200 headers plus one chunk remained pending with its socket open at 15.755 seconds.
  • Controlled native loopback after fix: settled at about 15.258 seconds with the exact retryable abort reason, closed the stalled socket, and an identical healthy retry saved four bytes.
  • External live gate from exact candidate code: one read-only GET to LINE Get Content with a synthetic invalid bearer and synthetic message ID rejected safely as HTTP 404 in 760 ms. It created no media/temp residue, performed no send or persistent write, closed the dispatcher, left no network resources, and removed its isolated state root. No real credentials or user content were used.
  • Focused lifecycle proof: OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs extensions/line/src/download.test.ts extensions/line/src/bot-handlers.test.ts extensions/line/src/webhook-spool.test.ts extensions/line/src/monitor.lifecycle.test.ts --reporter=verbose — 81 tests passed. The body-stall and ingress-cancellation regressions failed on pre-fix code for the intended reasons.
  • Production/test types, type-aware extension lint, formatting, media-download ownership guard, database-first guard, import cycles, and diff checks passed. Pinned Undici 8.9.0 source and the official LINE 202/200 content contract were inspected.
  • Exact-head CI: run 31950487996 completed successfully on e0cd3b87953c650d7de6147d8de8e4236fc8acad with 41 successful jobs and zero failures.
  • Fresh structured autoreview on the reviewed patch reported: autoreview clean: no accepted/actionable findings reported.
  • Test audit: the added tests protect observable total-deadline, exact-cancellation, resource-release, and healthy-retry behavior at the download/lifecycle boundaries; they add no test-only production seam.

Production LOC: +61/-35 (net +26). Tests: +87/-10 (net +77). The production growth is the minimum owner-held signal/deadline composition and reader cleanup needed to cover headers through EOF and ingress shutdown without adding config, fallback, or parallel policy paths.

Duplicate search found closed #109165 and closed #86873. #109165 used separate 15-second readiness and 120-second body budgets, did not propagate durable-ingress cancellation, exposed a test-only timeout option, and lacked native transport cleanup proof; this change replaces that shape with the single owner deadline and lifecycle invariant above.

AI-assisted: yes. The implementation, dependency behavior, lifecycle ownership, tests, and live/controlled evidence were directly reviewed.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 16, 2026 13:40
@openclaw-barnacle openclaw-barnacle Bot added channel: line Channel integration: line size: S maintainer Maintainer-authored PR labels Aug 16, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 9:46 AM ET / 13:46 UTC.

ClawSweeper review

What this changes

The PR extends LINE inbound-media cancellation and the existing 15-second deadline from readiness polling through response-body EOF, and stops pre-adoption work when durable ingress is cancelled.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer merge review. The patch repairs the owner boundary that currently clears its deadline at response headers, but merging deliberately makes a slow post-header LINE transfer retry after the shared 15-second budget.

Priority: P1
Reviewed head: e0cd3b87953c650d7de6147d8de8e4236fc8acad
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused behavior proof and boundary tests support the repair, with the intended full-transfer timeout policy left for maintainer acceptance.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides exact-head controlled native loopback before/after output for the stalled response body and a safe live endpoint check, with observed recovery and resource closure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides exact-head controlled native loopback before/after output for the stalled response body and a safe live endpoint check, with observed recovery and resource closure.
Evidence reviewed 8 items Current-main failure path: Current main starts a 15-second readiness timer, returns a 200 response, and clears that timer before the body reader completes; the reader then awaits each body read without its own deadline.
PR owner-boundary repair: The PR composes the ingress signal with a single deadline, carries it into fetch and body reads, and retires it only at EOF or final cleanup.
Caller and lifecycle boundary: The inbound handler supplies the durable-ingress abort signal to the download and rethrows its exact cancellation reason before materializing the event context.
Findings None None.
Security None None.

How this fits together

LINE webhook events download inbound attachments before the event is handed to agent processing. The LINE plugin owns readiness polling and response consumption, then passes a completed attachment to shared media storage and message dispatch.

flowchart LR
  A[LINE webhook event] --> B[LINE event handler]
  B --> C[Media readiness and download]
  C --> D[Deadline or ingress cancellation]
  D --> E[Shared media storage]
  E --> F[Agent message dispatch]
Loading

Decision needed

Question Recommendation
Is a 15-second total budget, including LINE 202 preparation and the full media-body transfer, acceptable for existing default-path inbound media? Accept the bounded retry policy: Land after exact-head CI completes, accepting that transfers exceeding the single owner-held budget retry rather than remain active indefinitely.

Why: Current main permits an unbounded post-header transfer, while this PR intentionally changes slow successful transfers into durable retries; that availability tradeoff requires maintainer intent.

Before merge

  • Resolve merge risk (P1) - A valid existing LINE media transfer that needs more than 15 seconds after headers—or reaches headers late after 202 polling—will now enter durable retry instead of completing in that attempt.
  • Resolve merge risk (P1) - Production code grows by 26 lines; no net-neutral refactor is evident because the old readiness-only timer must become an owner-held signal spanning fetch, body consumption, and reader cleanup.
Agent review details

Security

None.

PR surface

Source +26, Tests +77. Total +103 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 61 35 +26
Tests 2 87 10 +77
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 148 45 +103

Review metrics

Metric Value Why it matters
Production versus regression-test delta production +26, tests +77 The production growth is confined to deadline/signal composition and response cleanup; the test growth covers the stalled-body and ingress-cancellation boundaries.

Root-cause cluster

Relationship: canonical
Canonical: #124606
Summary: This PR is the current canonical proposed repair for the LINE post-header media stall; the two earlier overlapping proposals are closed and unmerged.

Members:

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

Merge-risk options

Maintainer options:

  1. Accept bounded retries for slow media (recommended)
    Land after exact-head CI if maintainers accept that a transfer exceeding the shared 15-second budget retries instead of holding durable ingress indefinitely.
  2. Increase the shared budget before merge
    Choose a larger single owner-held limit and add focused coverage for late readiness plus slow valid body delivery if existing LINE media needs more transfer time.

Technical review

Best possible solution:

Keep one LINE-owned deadline and cancellation flow, and land it only after a maintainer accepts the 15-second full-transfer retry tradeoff and queued exact-head checks complete.

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

Yes—source proves that current main clears the only deadline at headers while the following body reader can remain pending; this read-only review did not execute the pre-fix scenario.

Is this the best way to solve the issue?

Unclear—the owner-boundary implementation is sound, but a maintainer must decide whether the single 15-second budget is the right default for slow valid media.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A stalled inbound LINE attachment can leave a user event unfinished before agent dispatch.
  • add merge-risk: 🚨 message-delivery: The new full-transfer deadline can retry valid but slow existing inbound media that current main would continue reading.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head controlled native loopback before/after output for the stalled response body and a safe live endpoint check, with observed recovery and resource closure.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-head controlled native loopback before/after output for the stalled response body and a safe live endpoint check, with observed recovery and resource closure.

Label justifications:

  • P1: A stalled inbound LINE attachment can leave a user event unfinished before agent dispatch.
  • merge-risk: 🚨 message-delivery: The new full-transfer deadline can retry valid but slow existing inbound media that current main would continue reading.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-head controlled native loopback before/after output for the stalled response body and a safe live endpoint check, with observed recovery and resource closure.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head controlled native loopback before/after output for the stalled response body and a safe live endpoint check, with observed recovery and resource closure.

Evidence

What I checked:

  • Current-main failure path: Current main starts a 15-second readiness timer, returns a 200 response, and clears that timer before the body reader completes; the reader then awaits each body read without its own deadline. (extensions/line/src/download.ts:83, 605dece17105)
  • PR owner-boundary repair: The PR composes the ingress signal with a single deadline, carries it into fetch and body reads, and retires it only at EOF or final cleanup. (extensions/line/src/download.ts:165, e0cd3b87953c)
  • Caller and lifecycle boundary: The inbound handler supplies the durable-ingress abort signal to the download and rethrows its exact cancellation reason before materializing the event context. (extensions/line/src/bot-handlers.ts:425, e0cd3b87953c)
  • Shared storage ownership: The shared media store writes to a sibling temporary file and atomically publishes only after stream consumption, so LINE correctly owns its transport deadline while storage retains cleanup ownership. (src/media/store.ts:619, 605dece17105)
  • Regression coverage: The added tests cover a post-header stalled body, reader release, a healthy retry, and ingress cancellation before context construction; these are behavior-boundary regressions rather than test-only seams. (extensions/line/src/download.test.ts:386, e0cd3b87953c)
  • Feature history: The current implementation dates to Peter Steinberger's 32ddbb3 commit; prior LINE media readiness and retry work is recorded in Eden's aea825f and 2e16660 commits. (extensions/line/src/download.ts:19, 32ddbb3be23e)

Likely related people:

  • steipete: Current main attributes the central LINE download implementation to this author, and this PR continues that owner-boundary work. (role: current LINE media implementation author and recent area contributor; confidence: high; commits: 32ddbb3be23e, e0cd3b87953c; files: extensions/line/src/download.ts, extensions/line/src/bot-handlers.ts)
  • Eden: History credits this contributor with the 202 readiness and durable-ingress retry work that the new deadline preserves. (role: prior LINE retry-path contributor; confidence: high; commits: aea825f9d93e, 2e16660f18b9; files: extensions/line/src/download.ts, extensions/line/src/bot-handlers.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the 15-second total-transfer policy and wait for queued exact-head CI before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

@steipete
steipete merged commit 51964c1 into main Aug 16, 2026
174 of 179 checks passed
@steipete
steipete deleted the fix/autoqa-plugin-response-deadline-v3 branch August 16, 2026 13:52
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

channel: line Channel integration: line maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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.

1 participant