Skip to content

rpcs can fail with "unable to connect to service" for 30s+ after session suspend #18208

Closed

Description

@kevinushey

Symptom

After a session suspend (observed with a forced suspendSession, but any suspend that races an incoming request should qualify), RPCs sent to the session can fail with

Error: jsonrpc error 1 (Unable to connect to service)

for 30 seconds or more, even though nothing is wrong with the session itself -- the very next RPC after the failures relaunches the session and succeeds within a couple of seconds. In the IDE this surfaces as the error above printed in the console when the user types during the window; in CI it surfaced as the session_suspend.test.ts e2e failure on PR #18203 (run 29273786621-1, server-linux).

Root cause

rserver already buffers proxied RPCs across a session restart: proxyRpcRequest attaches sessionRetryProfile (ServerSessionProxy.cpp), which retries the session connection every 25ms for up to rsession-proxy-max-wait-secs (default 30s) and, on the first failed attempt, relaunches the session via launchSessionRecovery.

The failure mode is a stuck state in that recovery path:

  1. The first post-suspend RPC's launchSession races the still-exiting suspended session and the launched process dies (or never becomes connectable), but the launch is recorded in pendingLaunches_.
  2. SessionManager::launchSession returns early ("launch already pending") for any pending entry younger than one minute (ServerSessionManager.cpp, launchSession), and launchSessionRecovery only launches when firstAttempt is true -- so neither the remaining 30s of that RPC's polling nor any subsequently arriving RPC re-attempts the launch. Every request buffered in this window burns its full 30s and fails with errc::ConnectionError (mapped to "jsonrpc error 1").
  3. The stale entry is only cleared when a failing RPC's handleRpcError calls removePendingLaunch (ServerSessionProxy.cpp) -- which is why the next RPC after the 30s failures relaunches successfully.

Timeline evidence from the failing e2e trace: two console inputs submitted at 18:46:01 and 18:46:03 both returned the JSON-RPC ConnectionError envelope ~30s later; a third input at 18:46:33 (immediately after the first error handler cleared the pending launch) relaunched the session and succeeded.

Proposed fix

Make the buffered-RPC recovery self-healing instead of one-shot:

  • Re-attempt launchSession from the retry loop rather than only on the first attempt, letting the pendingLaunches_ bookkeeping dedupe concurrent launches.
  • Treat a pending launch as stale once its launched process is known to be dead (local launches can observe child exit), rather than relying on the fixed one-minute age check.

The e2e-side false-pass that let a test wedge on this window was fixed separately in #18207.

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

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions