Skip to content

hold rpc requests until client_init has returned - #18802

Merged
kevinushey merged 1 commit into
mainfrom
bugfix/queue-rpcs-until-client-init
Sep 13, 2026
Merged

kevinushey merged 1 commit into
mainfrom
bugfix/queue-rpcs-until-client-init

Conversation

@kevinushey

@kevinushey kevinushey commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #18797, which showed how little it takes to bring a session down from the client side.

Problem

Until client_init returns, RemoteServer has no client id, so any other RPC goes out without one. The session rejects it with INVALID_CLIENT_ID, and RemoteServer.handleRpcErrorInternally treats that code as "another client took over": it calls disconnect() and fires ClientDisconnectedEvent, which tears down the workbench. On desktop this is silent (the disconnected UI is server-only); on the server it leaves the workbench behind a glass pane.

Any early sender triggers it: an AceEditor.load() callback, a Scheduler.scheduleDeferred in an eagerly-constructed singleton, or logException for an exception thrown during startup. It never reproduces on desktop, where the session is up before the page loads and client_init returns in milliseconds, and only shows up on server CI, where client_init takes seconds while rserver launches the session -- and there it looks like a pile of unrelated project-switch flakes. In #18797's first run, 85 of 226 client_init calls on the linux-server shards had such a request racing them.

Change

RemoteServer.sendRequest now holds requests while clientId_ is null, the same way it already holds them while unauthorized, and sends them (with the id filled in) as soon as the client_init response arrives. client_init itself, auth_status, and abort (the "R is taking longer to start" dialog's Terminate R / Safe Mode buttons) still go straight out; the exemption list is a protected method so it can be extended. Each held request is logged via Debug.log, so a client_init race stays visible in the console without being fatal. RpcRequest gains setClientId for the replay and an isCancelled flag so a request cancelled while held is dropped rather than sent.

Satellite windows proxy their RPCs through the main window's RemoteServer, so they are covered by the same guard.

Verified with ant javac, and console_editor_keybindings.test.ts + project_editor_theme.test.ts on desktop against the worktree's ant draft build (8 passed). The server-side case is exercised by the PR-triggered linux-server e2e shards.

Before client_init completes the client has no client id, and the
session answers any other request with INVALID_CLIENT_ID. RemoteServer
reads that as "another client took over" and disconnects, so a single
early request (an AceEditor.load() callback, a logged exception) took
the whole session down -- silently on desktop, and behind a glass pane
on the server, where client_init takes seconds while rserver launches
the session. Queue such requests, fill in the client id when
client_init returns, and send them then. client_init itself, the auth
watcher, and abort (the slow-start dialog's buttons) still go straight
out.

Claude-Session: https://claude.ai/code/session_01E9g2VQQ2BTypGPabh1NBkP
@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

2 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
2909 2 186 10
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 10 0
❌ desktop-linux 730 1 38 3
✅ desktop-macos 738 0 33 2
✅ desktop-windows 733 0 41 4
❌ server-linux 678 1 44 1
✅ setup 28 0 20 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit 1fa6ab51982f90fe13f5eaa1b77e1fba62c897fe - Run #975

@kevinushey
kevinushey merged commit 1dac867 into main Sep 13, 2026
32 of 34 checks passed
@kevinushey
kevinushey deleted the bugfix/queue-rpcs-until-client-init branch September 13, 2026 04:57
kevinushey added a commit that referenced this pull request Sep 13, 2026
Two linux CI flakes from the PR #18802 run (34712089464):

- spelling_language_switch "rechecks an open detached editor" looked up
  the satellite's Ace editor right after 'domcontentloaded', which is the
  popup's initial document -- GWT mounts the editor later. The lookup
  throws until then, and expect.poll propagates a throw instead of
  retrying, so the test died ~70ms after the popup opened. Red on
  desktop-linux since #18766 and now on linux-server too. Poll with
  toPass so the throw is retried.

- highlight_active_tabs read the selected tab's indicator geometry once.
  Selecting a partly hidden tab animates the strip to reveal it, and
  DocTabLayoutPanel keeps the clipped (position: absolute) variant until
  that scroll settles, so a one-shot read could see 'absolute' where the
  test expects 'fixed'. Poll the geometry until it settles.

This branch was previously deployed

1 inactive deployment
e2e-playwright — 1fa6ab51 Deployed Sep 12, 2026 by kevinushey via windows / e2e-desktop-windows (6) #975
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant