Skip to content

fix(cancelled-trace bug): quiet ConnectionClosedOK on HUDRuntime tunnel close - #693

Draft
lukass16 wants to merge 1 commit into
mainfrom
lukass/cancelled-trace-bug
Draft

lukass16 wants to merge 1 commit into
mainfrom
lukass/cancelled-trace-bug

Conversation

@lukass16

@lukass16 lukass16 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Part of the HUDRuntime cancelled-trace bug (counterpart: https://github.com/hud-evals/hud-monorepo/pull/2144). Low priority, draft. Supersedes #692, which GitHub closed when its branch was renamed.

What

When the HUD runtime gateway closes a tunnel websocket normally (code 1000) while the local side is still relaying, _splice_websocket re-raised websockets.ConnectionClosedOK out of the asyncio.start_server callback, so asyncio logged it as an unhandled exception even though nothing failed.

_splice_websocket now treats ConnectionClosedOK as a clean end of the relay. All other relay errors still propagate.

Scope

SDK-only log-noise fix. It does not fix the platform marking local-agent HUDRuntime traces cancelled; that is the separate monorepo PR (runtime-session DELETE cancels the still-running attached trace before /trace/{id}/exit arrives). Independent of any other open PR; based on main.

Tests

  • New test_splice_websocket_treats_normal_close_as_clean_end fails on main, passes here.
  • hud/eval/tests/test_hosted.py: 41 passed; ruff format/check and ty clean.

Note

Low Risk
SDK-only logging/exception-handling tweak in the websocket relay path; real relay failures still propagate.

Overview
HUDRuntime tunnel relay no longer surfaces websockets.ConnectionClosedOK as an unhandled error when the gateway closes the tunnel websocket normally (close code 1000) during TCP↔WS splicing.

_splice_websocket still re-raises every other relay exception; only a normal close is swallowed so asyncio does not log a spurious failure.

Adds test_splice_websocket_treats_normal_close_as_clean_end alongside the existing relay-error propagation test.

Reviewed by Cursor Bugbot for commit 56bbd62. Bugbot is set up for automated code reviews on this repo. Configure here.

…D tunnel

Co-authored-by: Lukass Kellijs <lukass16@users.noreply.github.com>
@cursor
cursor Bot force-pushed the lukass/cancelled-trace-bug branch from 21c03e4 to 56bbd62 Compare October 13, 2026 19:31
@lukass16
lukass16 marked this pull request as ready for review October 13, 2026 19:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T19:41:06.265472Z 56bbd62 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56bbd62c0e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

await asyncio.sleep(60.0)
raise StopAsyncIteration

await _splice_websocket(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exercise the normal runtime connection lifecycle

This regression test calls the private _splice_websocket helper directly, bypassing _forward_runtime_connection and the asyncio.start_server callback where the reported unhandled exception is observable. It therefore does not verify that a normal gateway close completes cleanly through the actual runtime lifecycle; mock the websocket boundary while driving a HUDRuntime connection instead.

AGENTS.md reference: AGENTS.md:L126-L132

Useful? React with 👍 / 👎.

@lukass16
lukass16 marked this pull request as draft October 13, 2026 19:47

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants