Repository navigation
fix(desktop): classify retired-socket ENOTCONN as expected teardown (#9666) - #9789
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 connectedSentry 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 inRealtimeHubCloseClassifier, soshouldReportToSentryreturnedtrueand 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:.expectedIdleTeardown, not reportedScope 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.