Skip to content

Restart R silently skips its completion event when the session takes more than ~10s to answer #18870

Closed

Description

@kevinushey

Summary

When a Restart R takes more than about 10 seconds to produce a session that answers a ping, RStudio stops waiting for it, logs Error connecting with session. to the browser console, and never fires ConsoleRestartRCompletedEvent -- even though the session does come back a moment later.

The same thing happens if the very first ping fails: since #17906, one failed ping ends the wait outright, so the retry that would have reached the new session is never sent.

Symptoms

Anything hanging off ConsoleRestartRCompletedEvent is silently skipped for that restart:

  • the console prompt is not nudged and the console does not take focus (Shell.onRestartRCompleted)
  • the Console pane's interpreter version is not refreshed, so a restart into a different R keeps showing the old version (ConsoleTabPanel -> ConsoleInterpreterVersion.adaptToR)

The restart itself still completes -- onCompleted runs, the progress indicator is dismissed and RestartStatusEvent.RESTART_COMPLETED fires -- so the failure is quiet.

Cause

SessionOpener.sendPing schedules a RepeatingCommand every 200ms with maxRetries = 50, and increments retries_ on every tick, including ticks where a ping is already in flight and nothing is sent. The budget is therefore a flat ~10.2s of wall clock no matter how many pings were actually attempted. When it runs out the loop marks itself completed; the ping that eventually succeeds is then discarded by the if (completed_) return; guard in onSuccess, so the event never fires.

A ping can legitimately stay unanswered for far longer than 10s: on Server, rserver holds an RPC aimed at a session it is still relaunching (up to rsession-proxy-max-wait-secs, default 30s), and the new session still has to restore the workspace and search path.

The onFailure path is the second half of it. Before #17906 a failed ping was retried and a later success still fired the event; that commit correctly made onCompleted fire exactly once, but also made the first failure terminal, which leaves maxRetries effectively unused.

Reproduction

Most visible in CI: the e2e test e2e/rstudio/tests/panes/console/interpreter_version.test.ts (added in #18858) restarts R twice on RStudio Server, where each restart takes 9-11s -- straddling the 10.2s budget. It currently fails on essentially every linux-server run, e.g. https://github.com/rstudio/rstudio/actions/runs/35259099463/job/105336330462, with the second restart's ping answered at 10.9s and its success discarded.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions