Repository navigation
Description
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:
- The first post-suspend RPC's
launchSessionraces the still-exiting suspended session and the launched process dies (or never becomes connectable), but the launch is recorded inpendingLaunches_. SessionManager::launchSessionreturns early ("launch already pending") for any pending entry younger than one minute (ServerSessionManager.cpp,launchSession), andlaunchSessionRecoveryonly launches whenfirstAttemptis 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 witherrc::ConnectionError(mapped to "jsonrpc error 1").- The stale entry is only cleared when a failing RPC's
handleRpcErrorcallsremovePendingLaunch(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
launchSessionfrom the retry loop rather than only on the first attempt, letting thependingLaunches_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.
Activity
clear pending session launches when the launched process dies (#18209)