Repository navigation
Description
System details
RStudio Edition : Desktop
RStudio Version : built from source at commit 07b27665d27822f1c7a36c609fe00ae81c549f1b
(first occurrence) and 6453ef9272bdbc8fff1f8045f873238e3827cec9
(second occurrence)
OS Version : Windows Server 2025 (GitHub Actions windows-2025 hosted runner)
R Version : 4.5.3
Steps to reproduce the problem
Seen twice on the Windows desktop e2e engine
(os-test-e2e-rstudio-desktop-os-windows-server-2025.yml), shard 4 of 4, in CI
rather than through interactive use. The two runs were built from different
commits, so this isn't a single bad build:
- https://github.com/rstudio/rstudio/actions/runs/31500379312/job/93818357157
- https://github.com/rstudio/rstudio/actions/runs/31535746560/job/93932162083
- Run the Windows desktop e2e engine.
- The sandbox warmup launch and the first several test launches all succeed,
each reachingwindow.rstudio.ready === truein roughly 4.4 seconds.
- The sandbox warmup launch and the first several test launches all succeed,
- Partway through the shard a launch stops connecting, and every launch after
it fails the same way for the remainder of the job.- RStudio processes keep being spawned throughout, with new PIDs each time.
End-of-job cleanup terminates orphanedrstudio(PID 8996) and
rsession-utf8(PID 8372) processes.
- RStudio processes keep being spawned throughout, with new PIDs each time.
launchRStudioretries once (2 attempts,e2e/rstudio/fixtures/desktop.fixture.ts:344-360),
then throws, failing that test's launch.- The next test's launch fails identically, and so on until the job ends.
- 138
[launch] attemptfailures across roughly 110 minutes, in both runs. - No test result is ever recorded: zero passes, zero failures.
- 138
- The no-output watchdog in
e2e/rstudio/scripts/run-with-heartbeat.mjsnever
fires.- Its idle timer resets on any child output (
resetTimer()is called from
both the stdout and stderr handlers, lines 102-103), and each failed retry
writes aconsole.warn, so a run making no progress still looks alive.
- Its idle timer resets on any child output (
- The job runs until GitHub's
timeout-minutes: 120cutoff and is recorded as
cancelled. Both occurrences ran almost exactly 2 hours.- This also holds the workflow's concurrency group. In the first occurrence a
newer push to the same PR sat queued behind it for about an hour, and an
explicitgh run canceldid not take effect either -- the job only ended
at the timeout.
- This also holds the workflow's concurrency group. In the first occurrence a
The transition, from the second run. Note that healthy launches take 3 seconds
from cleanup to process start, while the one that first fails takes 18:
21:30:36 Cleaning up any RStudio on port 9867...
21:30:39 Starting RStudio with CDP on port 9867...
21:30:39 RStudio process started (PID: 7316)
21:30:45 [launch-timing] + 4399ms window.rstudio.ready === true
21:30:54 Cleaning up any RStudio on port 9867...
21:30:57 Starting RStudio with CDP on port 9867...
21:30:57 RStudio process started (PID: 1504)
21:31:03 [launch-timing] + 4395ms window.rstudio.ready === true
21:31:19 Cleaning up any RStudio on port 9867...
21:31:22 Starting RStudio with CDP on port 9867...
21:31:22 RStudio process started (PID: 3816)
21:31:29 [launch-timing] + 4657ms window.rstudio.ready === true
21:32:26 Cleaning up any RStudio on port 9867...
21:32:44 Starting RStudio with CDP on port 9867...
21:32:44 RStudio process started (PID: 9380)
21:33:16 [launch] attempt 1/2 failed: Failed to connect to CDP at http://127.0.0.1:9867 within 30000ms: browserType.connectOverCDP: Timeout 5000ms exceeded.
21:33:16 Cleaning up any RStudio on port 9867...
The first failure reports Timeout 5000ms exceeded. Every one after it reports
ECONNREFUSED, and continues doing so for the rest of the job:
21:33:33 RStudio process started (PID: 1160)
21:34:02 RStudio process started (PID: 4708)
21:34:32 [launch] attempt 1/2 failed: Failed to connect to CDP at http://127.0.0.1:9867 within 30000ms: browserType.connectOverCDP: connect ECONNREFUSED 127.0.0.1:9867
21:34:49 RStudio process started (PID: 7944)
21:35:38 RStudio process started (PID: 1376)
21:36:08 [launch] attempt 1/2 failed: Failed to connect to CDP at http://127.0.0.1:9867 within 30000ms: browserType.connectOverCDP: connect ECONNREFUSED 127.0.0.1:9867
and, nearly two hours later, still the same, until the job is cut off:
23:22:04 [launch] attempt 1/2 failed: Failed to connect to CDP at http://127.0.0.1:9867 within 30000ms: browserType.connectOverCDP: connect ECONNREFUSED 127.0.0.1:9867
23:22:21 Terminate orphan process: pid (8996) (rstudio)
23:22:21 Terminate orphan process: pid (8372) (rsession-utf8)
Describe the problem in detail
Once RStudio stops being reachable over CDP partway through a shard, nothing
detects that every subsequent test is failing for the same reason. The
per-launch retry is correctly bounded at 2 attempts, but there is no
shard-level circuit breaker for "N consecutive launches have failed, stop
trying." The heartbeat watchdog was written for this class of problem and does
work -- it caught a genuinely silent hang in the same batch of runs, reporting
run-with-heartbeat: no output for 300s -- treating the run as hung and terminating it -- but it cannot see this shape, because the retry loop's own
logging keeps its idle timer alive. The result is a shard that occupies a
Windows runner for two hours, produces no test signal at all, and blocks other
queued runs in the same concurrency group.
Noted as an open question rather than a diagnosis: it isn't clear why the port
stops accepting connections. Seven launches on port 9867 succeed and then none
do, while RStudio processes continue to spawn without binding it. That could be
RStudio failing to open its remote-debugging port on a later relaunch, or the
harness's between-launch cleanup (Cleaning up any RStudio on port 9867...)
leaving state that prevents rebinding -- the longer 18-second gap on the failing
launch may be a clue. Nothing in the logs distinguishes those, so this report
doesn't assume either, and the request below is only about how the harness
responds.
Describe the behavior you expected
A shard would ideally give up after a small bounded number of consecutive launch
failures and fail red within a few minutes, so that an environment problem
doesn't cost two hours of a Windows runner, surfaces a clear reason in the
report, and doesn't hold the concurrency group against newer runs.
Activity
ronblum commentedon Aug 12, 2026
Recurred again on the Windows desktop e2e engine, same CDP-connection-loss pattern: after a restart, RStudio starts but Playwright can't connect to CDP, retries are exhausted, and the next test's launch fails the same way.
Unlike the earlier occurrences, these tests resolved to real fail/skip verdicts instead of hanging for the rest of the job.
kevinushey commentedon Aug 12, 2026
Root cause found -- the open question ("why does the port stop accepting connections?") is answerable, and the trigger is the same in all three occurrences:
uninstall-posit-ai.test.tstest 4, which uninstalls Posit Assistant and restarts RStudio.The restart instance is spawned by the dying Electron main (
ApplicationLaunch.launchRStudio), and on Windows Node'sspawncreates children withbInheritHandles=TRUE-- so the restarted, non-CDP instance silently inherits the old main's CDP listen socket handle. Normally harmless, becauserelaunchAfterRestartkills the whole restarted tree. But its "PIDs before restart" snapshot is taken after the Yes click, racing the restart spawn: on a loaded runner the restarted main is already up, lands in the "before" set, and the before/after diff spares it. Both job logs show the signature -- one PID present in both snapshots (run 1: 2748, run 2: 8996), and that exact PID plus anrsession-utf8are the orphan pair end-of-job cleanup terminates two hours later.The spared orphan keeps the port in LISTEN with nobody accepting, which explains every observed detail:
Timeout 5000ms exceeded(connects queue in the ~10-entry accept backlog and the HTTP request never gets answered; one 30s launch loop makes ~6 attempts, under the limit);ECONNREFUSED(backlog full -> Windows RSTs new SYNs);Get-NetTCPConnectionsees the zombie listener, but itsOwningProcessis the dead creator PID (socket ownership is recorded at creation, not per handle-holder), soStop-Processis a silent no-op;WSAEADDRINUSEon the port and continues without DevTools, so nothing ever listens properly again.The third occurrence recovering into real fail/skip verdicts is consistent with the spared PID there (5760) being a recycled-PID helper rather than the main, so the inherited handle died when the main was killed.
Fixes in #18538: the relaunch kill now diffs against a caller-provided snapshot taken before the restart is triggered, keyed on (pid, start time); a launch now fails immediately with the real reason when a LISTEN socket on the CDP port survives cleanup; and a consecutive-launch-failure circuit breaker (default 3,
PW_LAUNCH_FAILURE_STREAK_LIMIT) makes a broken shard fail red in minutes instead of running out the 2h job timeout behind the heartbeat watchdog.ronblum commentedon Aug 13, 2026
Another occurrence, on an unrelated PR (
bugfix/environment-restart-connection-error): https://github.com/rstudio/rstudio/actions/runs/31639429483/job/94271140723139 "Failed to connect to CDP" failures, job cancelled rather than completing. Confirms this isn't tied to any particular PR's changes.
e2e: fix relaunch pid-diff race; fail fast when launches keep failing (…
Fix two e2e test bugs and report why an RStudio launch failed (#18740)