Repository navigation
Suppress INVALID_CLIENT_ID disconnect during R session restart - #17141
Conversation
During a deliberate restart, in-flight RPC requests (e.g. the event polling request) may return INVALID_CLIENT_ID after the R session resets. Previously this triggered disconnect() and fired ClientDisconnectedEvent, which: 1. Set the disconnected_ flag, silently breaking the ping loop in waitForSessionRestart that detects when the new session is ready. 2. Showed the 'R Session Disconnected' dialog (a separate bug). Track restart state in RemoteServer by subscribing to RestartStatusEvent. When a restart is in progress, suppress the disconnect + event for INVALID_CLIENT_ID errors, since they are expected and transient.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
ReviewThe code is clean — import ordering, handler registration pattern, early-return guard, field placement, comments, and style all match existing conventions. No issues from a code quality perspective. The silent-failure analysis found some deeper concerns worth discussing: 1.
|
- Stop the event listener when suppressing INVALID_CLIENT_ID during restart, so the get_events long-poll doesn't leave isListening_ in a zombie state (ensureListening can restart it when needed). - Add Debug.log with the RPC method name when suppressing, so there is runtime evidence of the suppression for debugging. - Clear restartInProgress_ in disconnect(), so a real disconnect for another reason (e.g. INVALID_CLIENT_VERSION) during restart resets the flag and doesn't suppress future INVALID_CLIENT_ID handling. See: #17141 (comment) The pre-existing gap in SessionOpener.sendPing (onCompleted not called on retry exhaustion) is tracked separately in #17143.
Summary
During a deliberate restart, in-flight RPC requests (e.g. the event polling request from
RemoteServerEventListener) may returnINVALID_CLIENT_IDafter the R session resets. Previously this triggereddisconnect()and firedClientDisconnectedEvent, which:disconnected_flag, silently breaking the ping loop inwaitForSessionRestartthat detects when the new session is ready.Fix
Track restart state in
RemoteServerby subscribing toRestartStatusEvent. When a restart is in progress, suppress thedisconnect()call andClientDisconnectedEventforINVALID_CLIENT_IDerrors, since they are expected and transient.This is a root-cause fix that complements the handler-level guards in #17139 / #17140.
Testing
waitForSessionRestartping loop continues operating through the restart windowINVALID_CLIENT_IDerrors (outside of restart) still trigger disconnect as before