Skip to content

fix(realtime): add timeout to WebRTC offer requests - #104662

Merged
steipete merged 4 commits into
openclaw:mainfrom
Alix-007:alix/realtime-webrtc-offer-timeout
Jul 12, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
Alix-007:alix/realtime-webrtc-offer-timeout

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Realtime WebRTC voice setup could remain stuck forever if the SDP offer endpoint returned headers but never completed the answer body. Stopping Talk during that stall also left the request and its deadline alive until the timeout fired.

Why This Change Was Made

The WebRTC transport now owns one pending offer request across both fetch() and response-body consumption. A 30-second deadline aborts a genuinely stalled exchange, while stop() clears that deadline and aborts the same request immediately. Identity-guarded cleanup prevents an older request from detaching a replacement request, and the timeout constant remains private instead of becoming a test-only production export.

This keeps cancellation at the transport that already owns the peer, microphone, media element, and stop lifecycle; it adds no configuration or cross-session policy.

User Impact

  • Stalled provider responses leave connecting state instead of hanging indefinitely.
  • Pressing Stop during setup returns Talk to idle immediately and releases the request, peer, and microphone.
  • Successful SDP setup cannot be invalidated later by a stale timeout.

Evidence

Prepared head: 222677b2c30bbfae7f36860c2a141a4ebce6bb03

  • Blacksmith Testbox through Crabbox tbx_01kxbr8kw8ywrht8vmmh244r1q: pnpm test ui/src/pages/chat/realtime-talk-webrtc.test.ts passed 21/21; targeted oxfmt --check and oxlint passed.
  • Source-blind full Control UI Chromium proof passed in 1.38s: Start Talk reached visible connecting state; Stop aborted the pending SDP answer before the deadline, closed one peer, stopped one microphone track, restored the Start voice input action, and left no voice error status.
  • Maintained live OpenAI smoke passed on the patch-equivalent prepared head with gpt-realtime-2.1: backend Realtime bridge connected; browser WebRTC received an SDP answer containing audio, applied the remote description, and reached connected.
  • Fresh autoreview passed with no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/29203900475
  • OpenAI API contract checked: the Realtime calls endpoint returns the SDP answer in the response body, so the deadline intentionally covers body consumption as well as initial response headers.

AI-assisted change.

@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. 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 real behavior proof before merge. Reviewed July 12, 2026, 2:32 PM ET / 18:32 UTC.

Summary
The PR adds a 30-second abort deadline to WebRTC SDP offer fetch and body reads, cancels pending offers when the transport stops, and adds lifecycle regression tests.

PR surface: Source +64, Tests +93. Total +157 across 2 files.

Reproducibility: yes. Current main can be reproduced by returning successful SDP response headers while leaving Response.text() pending indefinitely; the posted earlier-head Chromium transcript also demonstrates this scenario.

Review metrics: 1 noteworthy metric.

  • Offer deadline: 1 added at 30,000 ms. This new fixed cutoff determines when a realtime setup changes from waiting to failure and deserves explicit review.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof is added.

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

Rank-up moves:

  • Post redacted exact-head Chromium or Playwright output for both stalled-body timeout and stop-during-body-read behavior.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The earlier-head Chromium transcript convincingly proves the stalled-body timeout, but the current head adds stop cancellation and rejection normalization without refreshed runtime evidence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The fixed 30-second cutoff can reject an unusually slow but eventually successful offer exchange; no existing repository or upstream contract establishes this specific threshold.
  • [P1] The current head’s user-stop cancellation behavior has unit coverage but no refreshed real-browser evidence showing its final UI state and resource cleanup.

Maintainer options:

  1. Refresh exact-head browser proof (recommended)
    Run the latest head against a stalled SDP body and a user stop during body read, confirming final UI state and peer, media, and timer cleanup.
  2. Accept the proof gap
    A maintainer may accept the earlier timeout transcript plus current unit coverage while explicitly owning the unrecorded latest-head stop behavior.

Next step before merge

  • [P2] No mechanical code repair is identified; contributor-provided exact-head browser proof and owner acceptance of the fixed timeout threshold remain.

Maintainer decision needed

  • Question: Should the WebRTC offer exchange use an unconditional 30-second client deadline on the current head?
  • Rationale: The threshold resolves an indefinite hang but intentionally changes availability for slow successful exchanges, and repository behavior does not already define the cutoff.
  • Likely owner: steipete — He authored the current lifecycle refinements, is assigned to the PR, and is best positioned to accept the availability tradeoff.
  • Options:
    • Keep 30 seconds with proof (recommended): Retain the scoped deadline after exact-head browser evidence confirms timeout and user-stop cleanup behavior.
    • Revise the timeout policy: Select a different threshold or strategy before merge if slow offers should not fail unconditionally after 30 seconds.

Security
Cleared: The source-and-test-only browser lifecycle change introduces no dependency, permission, credential, artifact-download, or supply-chain concern.

Review details

Best possible solution:

Keep the deadline transport-local and internal, spanning fetch and body consumption, while preserving stop as silent cancellation and proving both lifecycle outcomes on the exact current head.

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

Yes. Current main can be reproduced by returning successful SDP response headers while leaving Response.text() pending indefinitely; the posted earlier-head Chromium transcript also demonstrates this scenario.

Is this the best way to solve the issue?

Yes. A transport-owned AbortController spanning fetch and body consumption is the narrowest maintainable fix and avoids a global timeout, retry layer, or new configuration surface.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: The PR fixes a real but bounded Control UI realtime setup hang with limited blast radius.
  • merge-risk: 🚨 availability: The new fixed deadline can terminate slow offer setup, and the current-head cancellation path lacks real-browser proof.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The earlier-head Chromium transcript convincingly proves the stalled-body timeout, but the current head adds stop cancellation and rejection normalization without refreshed runtime evidence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +64, Tests +93. Total +157 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 86 22 +64
Tests 1 93 0 +93
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 179 22 +157

What I checked:

Likely related people:

  • steipete: Authored the latest stop-abort and rejection-normalization changes, is currently assigned, and force-pushed the reviewed head. (role: recent adjacent contributor; confidence: high; commits: 27ad38c6da2c, 222677b2c30b; files: ui/src/pages/chat/realtime-talk-webrtc.ts, ui/src/pages/chat/realtime-talk-webrtc.test.ts)
  • Vincent Koc: Git history indicates the current WebRTC transport, caller, and adjacent test surface entered main through their commit. (role: behavior introducer; confidence: medium; commits: e999802e6e94; files: ui/src/pages/chat/realtime-talk-webrtc.ts, ui/src/pages/chat/realtime-talk-webrtc.test.ts, ui/src/pages/chat/chat-realtime.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 (6 earlier review cycles)
  • reviewed 2026-07-11T20:01:01.801Z sha bec8b67a364c687b1657602d3e3e8cee8243bf77 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T23:31:02.773Z sha 8af1b46d64b510ecd9f12feecfe3ab6f11bffa38 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T23:49:19.805Z sha 8baa2577891bfa2d014c9c2f21d17e399e2269c1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-12T00:34:16.169Z sha 8baa2577891bfa2d014c9c2f21d17e399e2269c1 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T10:04:28.148Z sha 5bbd118f1632e49ae3ea0adbd818efe82baac982 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T18:17:48.664Z sha 55f9f2b945c2b70a251203103991fc2949f4ca0e :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Jul 11, 2026
@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR body with exact-head browser proof at 8baa2577891bfa2d014c9c2f21d17e399e2269c1.

New proof ran Playwright Chromium against a Vite-served Control UI module harness and same-origin stalled SDP endpoint. It exercises attachChatRealtimeActions(...).toggleRealtimeTalk(), the browser fetch/body-read path, and the realtime state machine that drives the visible UI status.

Observed result: the browser sent the SDP POST, received response headers, then the intentionally open body was aborted after ~30s; the state ended at realtimeTalkStatus="error", realtimeTalkActive=false, peer closed, no remote description set, and media track stopped. Chromium surfaced the abort detail as The user aborted a request.; the lower-level unit test still covers the custom timeout reason.

This remains local browser proof, not live OpenAI Realtime proof.

@clawsweeper

clawsweeper Bot commented Jul 12, 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 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed 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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 12, 2026
@steipete steipete self-assigned this Jul 12, 2026
@steipete
steipete force-pushed the alix/realtime-webrtc-offer-timeout branch 2 times, most recently from f0d91da to 55f9f2b Compare July 12, 2026 18:10
@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 12, 2026
@steipete
steipete force-pushed the alix/realtime-webrtc-offer-timeout branch from 55f9f2b to 222677b Compare July 12, 2026 18:27
@steipete

Copy link
Copy Markdown
Contributor

Maintainer refactor and land-ready proof complete on 222677b2c30bbfae7f36860c2a141a4ebce6bb03.

What changed:

  • Made the WebRTC transport own the pending SDP offer request across both fetch and answer-body consumption.
  • stop() now clears the deadline and aborts that request immediately; stale finalizers cannot detach a replacement request.
  • Kept the 30-second stalled-response deadline private and added regressions for timeout, stop cancellation, and successful timer cleanup.

Proof:

  • Blacksmith Testbox through Crabbox tbx_01kxbr8kw8ywrht8vmmh244r1q: focused transport suite 21/21; targeted oxfmt and oxlint clean.
  • Source-blind full Control UI Chromium flow: visible connecting state, Stop-to-idle in 1.38s, offer signal aborted, peer closed once, microphone track stopped once, no setup error.
  • Maintained live OpenAI smoke on the patch-equivalent prepared head with gpt-realtime-2.1: backend bridge connected; browser WebRTC received audio SDP, installed the answer, and reached connected.
  • Fresh autoreview: clean, no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/29203900475

The fix is transport-local, adds no config surface, and matches the stop-during-start contract used by sibling Talk transports. Thanks @Alix-007 for the original fix and browser stalled-body reproduction.

@steipete
steipete merged commit 41a1fd6 into openclaw:main Jul 12, 2026
83 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 13, 2026
* fix(realtime): add timeout to WebRTC offer requests

* test(realtime): reject offer aborts with errors

* fix(ui): abort pending realtime offer on stop

* test(ui): normalize realtime abort rejection

---------

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

app: web-ui App: web-ui merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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.

2 participants