Skip to content

fix(desktop): classify retired-socket ENOTCONN as expected teardown (#9666) - #9789

Merged
kodjima33 merged 1 commit into
mainfrom
watchdog/issue-9666-openai-socket-rotation
Jul 15, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
watchdog/issue-9666-openai-socket-rotation

Conversation

@kodjima33

@kodjima33 kodjima33 commented Jul 15, 2026 •

Copy link
Copy Markdown
Collaborator

Bug

Issue #9666: macOS RealtimeHub should treat OpenAI's 60-minute session rotation as normal lifecycle without surfacing an error. After the rotation classifier landed (#9672), production still records a Socket is not connected Sentry cluster on the stable/beta cohorts (per the 2026-07-15 recurrence comments).

Root cause

When a write races the provider close, the retired OpenAI socket surfaces the failure as ENOTCONN — The operation couldn't be completed. Socket is not connected. That text matched no lifecycle category in RealtimeHubCloseClassifier, so shouldReportToSentry returned true and it was logged error-level. On an aged, idle socket (the window right after a 60-minute rotation) this is an expected transport teardown, not a provider error. The re-warm already happens on the nil-category aged path — only the classification, and thus the error-level Sentry event, was wrong.

Fix

Recognize ENOTCONN on an aged idle socket (aliveFor >= idleTeardownThreshold, no active turn) as .expectedIdleTeardown, mirroring the existing WebSocket-1008 idle-close gate: quiet re-warm, no Sentry error. A fast ENOTCONN, or one during an active turn, falls through and stays a reportable error, so genuine transport failures remain observable. Scope is the typed classifier boundary only — no call-site booleans, no send-path change.

Verification

  • xcrun swift build -c debug --package-path Desktop → Build complete.
  • xcrun swift test --filter RealtimeHubCloseClassifierTests → 13/13 pass, including 3 new cases:
    • aged idle ENOTCONN → .expectedIdleTeardown, not reported
    • active-turn ENOTCONN → nil, reported
    • fast ENOTCONN → nil, reported

Scope note

This eliminates the error-level Sentry noise for the expected rotation/teardown (acceptance criterion: "the known expiry no longer creates an error-level Sentry event; unexpected close/reconnect failure remains observable"). It does not add new send-path guards; the active-turn/fast ENOTCONN paths remain visible for further lifecycle work.

🤖 automated by hourly watchdog; opened for review, not merged.

Review in cubic

…9666)

macOS RealtimeHub rotates OpenAI sessions at the 60-minute limit, but a
write that races the provider close surfaces the retired socket as
`Socket is not connected` (ENOTCONN). That message matched no lifecycle
category, so it was logged error-level to Sentry — the residual
`Socket is not connected` cluster still firing on stable/beta cohorts
after the rotation fix (#9672) landed.

Root cause: the ENOTCONN close on an already-aged, idle socket is an
expected transport teardown, not a provider error. The re-warm already
happens; only the classification (and thus the error-level Sentry event)
was wrong.

Fix: recognize ENOTCONN on an aged idle socket (aliveFor >= idle
threshold, no active turn) as `.expectedIdleTeardown`, mirroring the
existing 1008 idle-close gate — quiet re-warm, no Sentry error. A fast
ENOTCONN or one during an active turn still falls through and remains a
reportable error, so genuine transport failures stay observable.

Tests: 3 new classifier cases (aged-idle → expected/no-report,
active-turn → reportable, fast → reportable). Full package builds; all
13 RealtimeHubCloseClassifierTests pass.

🤖 automated by hourly watchdog; opened for review, not merged.
@kodjima33
kodjima33 merged commit 2937569 into main Jul 15, 2026
19 of 23 checks passed
@kodjima33
kodjima33 deleted the watchdog/issue-9666-openai-socket-rotation branch July 15, 2026 14:39
@undivisible undivisible added the AI label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants