Repository navigation
Description
Summary
On RStudio Desktop, if the set_user_state RPC fails during workbench bootstrap, startup silently dead-ends and the user is left with an unrecoverable grey window (title bar and menu bar present, empty grey content). There is no retry, error dialog, or recovery; the session stays grey indefinitely until killed.
Observed once on a fresh install, first launch; a subsequent launch started normally. The failure is timing-dependent (a transient connection blip during bootstrap), so it is intermittent.
Environment
- RStudio 2026.06.0+240 (Blue Plumbago), Desktop
- Windows 11 Pro (10.0.26200)
- Electron 41.7.2
Symptoms
- Main window shows the title bar and menu bar, but the content area is blank grey. Waiting several minutes does not change it.
- DevTools console shows a single error:
Unable to establish connection with R session when executing 'set_user_state'Failed to load resource: net::ERR_CONNECTION_FAILED :<port>/rpc/set_user_state
- Killing the process via Task Manager and relaunching starts normally with no delay.
Root cause
The workbench bootstrap chains the IDE-building call behind two server RPCs, and only continues on success:
Application.java:271-287
// refresh prefs incase they were loaded without sessionInfo (this happens exclusively
// in desktop mode ...). ... in desktop mode that returns an incomplete set until the
// pref refresh has run.
userState_.get().writeState(boolArg -> // fires set_user_state
{
userPrefs_.get().writeUserPrefs(boolArg1 -> // fires set_user_prefs
{
...
initializeWorkbench(); // only runs if BOTH succeed
});
});UserState.writeState's error handler does not invoke the completion continuation:
UserState.java:82-91
if (onCompleted != null)
onCompleted.execute(true); // success path continues the chain
...
public void onError(ServerError error)
{
Debug.logError(error); // failure path logs and stops; onCompleted never called
}So when set_user_state fails at the TCP level (ERR_CONNECTION_FAILED):
onErrorlogs and returns. The continuation lambda (which runswriteUserPrefs(... initializeWorkbench())) never executes.initializeWorkbench()never runs, so the IDE is never built or painted -> permanent grey screen, no retry, no error UI.writeUserPrefs()never runs, so the user pref layers stay in the incomplete "loaded without sessionInfo" state that the comment atApplication.java:272-275describes.
Secondary effect: the only entry in the rsession log
Because the bootstrap RPCs failed at the TCP layer, those requests never reached rsession, so nothing about them appears in the rsession log. The only logged errors come later, when the user attempted to close/quit the grey window. Quitting routes through DesktopHooks.quitR() (DesktopHooks.java:204) -> quitSession command -> ApplicationQuit.onQuitSession() -> prepareForQuit() (ApplicationQuit.java:544-549), which lazily instantiates the Source pane for the first time. SourceColumnManager's state init reads a global pref:
SourceColumnManager.java:341-350
new JSObjectStateValue("source-column-manager", "column-info", ...)
{
protected void onInit(JsObject value)
{
if (!userPrefs_.allowSourceColumns().getGlobalValue()) // index-based global readgetGlobalValue walks the pref layers by index and dereferences each layer; with the layers still incomplete, layers_.get(i) is undefined:
Prefs.java:159-169
public T getGlobalValue()
{
for (int i = userLayer(); i >= 0; i--)
{
if (layers_.get(i).getValues().hasKey(name_)) // layers_.get(i) is undefinedPrefLayer.getValues() is return this.values; (PrefLayer.java:31-32), so an undefined layer produces Cannot read properties of undefined (reading 'values'). (Note the contrast with the project-aware getValue() at Prefs.java:145-156, which iterates with JsUtil.asReverseIterable and skips missing layers, so it does not throw.)
The rsession log shows exactly this, repeated for each close attempt:
ERROR CLIENT EXCEPTION: (TypeError): Cannot read properties of undefined (reading 'values');
Prefs.java#159::getGlobalValue
SourceColumnManager.java#348::onInit
... JSObjectStateValue ctor / GIN get SourceColumnManager -> get Source ...
ApplicationQuit.java#122::prepareForQuit
ApplicationQuit.java#545::onQuitSession
DesktopHooks.java#204::quitR
spanning ~15:17:59 to ~15:18:09 (four attempts), followed at ~15:19:22 by:
ERROR system error 5 (Access is denied); ... ChildProcess::terminate ... Win32ChildProcess.cpp:334
which is rsession failing to terminate a child while being force-killed by Task Manager (a consequence of the manual kill, not a cause).
So the grey screen and the getGlobalValue TypeError share one root cause: the failed set_user_state aborted bootstrap, leaving both an un-built workbench and incomplete pref layers.
Not yet determined: the trigger
Why set_user_state got ERR_CONNECTION_FAILED during bootstrap is not established. The GWT host page is served no-cache (GwtFileHandler.cpp:163) and the app clearly loaded, so rsession's listener was up at page-load time and then briefly unreachable for that RPC -- suggestive of a transient listener loss or reload/relaunch race during startup. Confirming this needs the desktop/Electron main-process log and a DEBUG-level rsession log, which were not captured in this occurrence (default log level).
The connection trigger is worth separate investigation, but it is secondary: a transient failure of one bootstrap RPC should not leave the user with an unrecoverable grey screen regardless of the cause.
Suggested remediation (for discussion, not yet implemented)
- Make bootstrap resilient to a failed
set_user_state/set_user_prefs: havewriteState'sonErroreither retry or invoke the continuation / route to the existing connection-error/reload UI, instead of silently stopping. - Defense-in-depth: guard the index-based accessors in
Prefs.java(getGlobalValue,getProjectValue,setGlobalValue) against a not-yet-populatedlayers_, returning the default when a layer is absent.
Related
- fix double-load and gray-screen on automation-agent startup #17733 (gray-screen on automation startup from an incomplete pref set) and the Global Options TypeError addressed in fix sccache wiring + Windows server race, macOS panmirror packaging, Global Options TypeError, and shiny test stability #17994 are the same family (reading prefs before layers are fully populated), but in different code paths; this bootstrap dead-end path is not covered by those fixes.
Activity
fix grey-screen dead-end when set_user_state fails during bootstrap (#…