Repository navigation
e2e: fix relaunch pid-diff race; fail fast when launches keep failing - #18538
Merged
Merged
Conversation
Three related fixes for the Windows shard that burned its full 2h job timeout after every RStudio launch stopped connecting over CDP: - relaunchAfterRestart now requires the caller to snapshot running RStudio processes BEFORE triggering the restart, keyed on (pid, start time). The restart instance is spawned by the dying Electron main, so the old post-click snapshot raced that spawn and could classify the new instance as pre-existing, sparing it. The spared orphan holds an inherited handle to the old main's CDP listen socket, keeping the port in LISTEN (unkillable via its owning PID, unbindable by every later launch) for the rest of the shard. - launchRStudioOnce now fails immediately, with the real reason, when a LISTEN socket on the CDP port survives cleanup, instead of spawning an RStudio that can never bind it. - launchRStudio now keeps a consecutive-failure streak in a sandbox file and refuses to launch once it crosses a threshold (default 3, PW_LAUNCH_FAILURE_STREAK_LIMIT to tune), so a broken environment fails the shard red in minutes instead of running out the job timeout behind the heartbeat watchdog. Addresses #18522.
kevinushey
temporarily deployed
to
e2e-playwright
August 12, 2026 21:31 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 12, 2026 21:31 — with
GitHub Actions
Inactive
kevinushey
had a problem deploying
to
e2e-playwright
August 12, 2026 21:33 — with
GitHub Actions
Failure
kevinushey
had a problem deploying
to
e2e-playwright
August 12, 2026 21:33 — with
GitHub Actions
Failure
kevinushey
temporarily deployed
to
e2e-playwright
August 12, 2026 21:34 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 12, 2026 21:34 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 12, 2026 21:35 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 12, 2026 21:35 — with
GitHub Actions
Inactive
kevinushey
had a problem deploying
to
e2e-playwright
August 12, 2026 21:35 — with
GitHub Actions
Failure
kevinushey
had a problem deploying
to
e2e-playwright
August 12, 2026 21:35 — with
GitHub Actions
Failure
RStudio E2E - all platforms3 test(s) failed
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #18522.
Root cause
All three occurrences transition at
uninstall-posit-ai.test.tstest 4, which uninstalls Posit Assistant and triggersdoRestart(). Two things combine:The restart instance is spawned by the dying Electron main (
ApplicationLaunch.launchRStudioinsrc/node/desktop/src/main/application-launch.ts) via Nodespawn, which on Windows creates children withbInheritHandles=TRUE-- so the restarted (non-CDP) instance inherits the old main's CDP listen socket handle.relaunchAfterRestartsnapshotted "PIDs before restart" after the test clicked Yes, racing that spawn. On a loaded runner the restarted main is already running when PowerShell samples the process list, lands in the "before" set, and is spared by the before/after diff -- only its helper children get killed.Both failing job logs show the signature: one PID present in both snapshots (run 1: 2748, run 2: 8996), and that exact PID plus an
rsession-utf8are the orphan pair the end-of-job cleanup terminates two hours later.The spared orphan keeps the port in LISTEN with nobody accepting: the first failed launch reports
Timeout 5000ms exceeded(connects queue in the ~10-entry accept backlog), every later oneECONNREFUSED(backlog full -> RST). The per-launch cleanup can't clear it -- the TCP table attributes the socket to its (dead) creator PID, soStop-Processis a no-op and every launch stalls the full 15s port-wait -- and each new Electron getsWSAEADDRINUSEon the port and silently continues without DevTools. Hence 138 failed launches across ~110 minutes with zero test results.Fixes
relaunchAfterRestartkill targeting: callers must now pass a snapshot taken withsnapshotRStudioProcesses()before triggering the restart, and the snapshot keys on (pid, start time) so a PID recycled by Windows can't masquerade as a pre-existing process. Sparing genuinely pre-existing instances (a developer's own RStudio) still works.launchRStudiotracks the consecutive-failure streak in a sandbox file (worker restarts don't reset it) and refuses further launches once it crossesPW_LAUNCH_FAILURE_STREAK_LIMIT(default 3). A broken shard now fails red in a few minutes instead of holding the runner and its concurrency group for the full 2h timeout.Verification
npm run typecheckpasses.snapshotRStudioProcesses()verified on macOS against a stand-inRStudioprocess (pid +lstartcaptured correctly).tests/harness/client_exceptions.test.ts(4 tests) passes on macOS through the modified launch path.