Skip to content

e2e: shards die with 300s output silence (heartbeat exit 124) in the projects test region #18394

Closed

Description

@kevinushey

Two shards of the same CI run (30472858712, on PR #18390) were killed by the heartbeat watchdog with the identical signature -- 300 seconds of total output silence -- in the same test neighborhood (the tests/projects/ serial region), on two different platforms and modes:

windows / e2e-desktop-windows (4) (job)

17:25:44  ok 132 [desktop-windows] > tests\projects\project_editor_theme.test.ts:199:7 > ... project without EditorTheme keeps global theme (20.2s)
17:30:44  ##[error]run-with-heartbeat: no output for 300s -- treating the run as hung and terminating it.

The hang began inside (or entering) the file's third test, project_editor_theme.test.ts:255 "project EditorTheme is not applied when project appearance settings are ignored". That test passed on linux-server the same day in ~31s.

linux-server / e2e-server-ubuntu (2) (job)

17:28:29  ok 255 [server-linux] > tests/projects/project_editor_theme.test.ts:255:7 > ... (passed)
17:28:48  ok 256 [server-linux] > tests/projects/project_trust_dialog.test.ts:329:7 > No trust dialog when no project is open @server_only @serial (12.3s)
17:29:00  Project created at: /tmp/workdir_45692ac203bb/trust_test_project
17:34:00  ##[error]run-with-heartbeat: no output for 300s -- treating the run as hung and terminating it.
17:34:30  ##[error]Process completed with exit code 124.

The Project created at: line is project_trust_dialog.test.ts:364, inside "Trust dialog appears and "Don't Trust" enables restricted mode" (:358) -- so createProjectViaUI and getWorkingDir succeeded, and the wedge is somewhere in the subsequent writeRprofile / restartRExpectingDialog stretch, before any of the bounded dialog-visibility probes.

Why this is a runner-level wedge, not a slow test

The suite's per-test timeout is 120s (playwright.config.ts). A hang inside a test body produces a Playwright timeout failure -- output -- at 120s, and the run continues. 300s of zero output means the worker process wedged hard enough that the reporter emitted nothing: neither shard ever printed a test-timeout failure for the test it died in.

Notes

  • The two hangs are in different tests (project_editor_theme.test.ts:255 on Windows desktop; project_trust_dialog.test.ts:358 on Linux server). The trust-dialog suite is @server_only, so the Windows hang cannot involve that file at all. What they share is the tests/projects/ serial region, project create/open/restart traffic, and the total-silence failure mode.
  • Unrelated to treat an empty PW_RSTUDIO_R_LIBS_USER as unset #18390's change on that run: Windows passes a real PW_RSTUDIO_R_LIBS_USER path and Linux Server never sets the variable (its log shows the harness-default library, fully populated, at 17:00).
  • The watchdog kill (exit 124) takes the entire remaining shard with it, so a single wedge costs ~35 minutes and every not-yet-run test on the shard.
  • Both jobs uploaded their artifacts after the kill, so blob reports/traces from the killed shards should be available on the run for triage.

Activity

  1. kevinushey commented on Jul 30, 2026

    @kevinushey
    CollaboratorAuthor

    Root-caused far enough to act. Summary of findings from the July occurrences (annotation sweep of all failed runs), the pw-sandbox/test-results artifacts of two killed shards (linux-desktop run 30580373239, windows run 30472858712), and a code trace of the shutdown/relaunch paths.

    Occurrences

    Every hit is in the tests/projects serial region, at a project open/close/switch (= session restart):

    When (UTC) Run Where it wedged
    7/23 01:39 29969220499 (PR #18337) linux-server, project_trust_dialog:358
    7/29 16:54 30472858712 (PR #18390) windows shard 4 (project_editor_theme:255) + linux-server shard 2 (project_trust_dialog:358)
    7/29 18:28 30480061844 (PR #18390) linux-desktop, in createAndOpenProject (GlobalOverride)
    7/30 02:14 30507911671 (PR #18399) linux-desktop, in createAndOpenProject (ProjectId)
    7/30 17:09 30564746898 linux-desktop, after project_id:101
    7/30 20:42 30580373239 (PR #18399) linux-desktop, entering the quarto create-project test
    7/30 20:43 30580434423 windows shard 4, after project_id:101

    (A 7/06 Fedora pair with the same exit code was a different thing entirely: >300s of silence while compiling R packages from source during the [r-libs] setup phase.)

    Why 300s of total silence (proven)

    The killed linux-desktop shard's test-results artifact contains an error-context.md for the wedged test with BOTH Test timeout of 120000ms exceeded and Test timeout of 120000ms exceeded while running "afterEach" hook. So Playwright's 120s timeout fired (silently), then the afterEach safety net hung against the dead session for another 120s, then fixture teardown kept going. The reporter only prints a result once the test fully finalizes, so the 300s heartbeat always wins, kills the shard, and the blob report is never written. Not a reporter bug -- just a consequence of hung teardown.

    What is actually wedging

    The wedged workers (and only those) were running the Posit Assistant chat backend + NES agent in every session:

    • positai.log in both sandboxes shows the backend starting with each session restart, then at the wedge moment: Received shutdown request from rsession -> Shutdown reason: close, grace period: 1000ms -> RStudio session services disposing -> end of log. (The backend's shutdown handler calls process.exit(0) before its final log line and has a 900ms force-exit backstop, so an abruptly-ending log is expected even for a healthy backend exit -- the backend is probably NOT the stuck process.)
    • The created project has no .Rproj.user and no new rsession ever logs anything: the replacement session was never launched.
    • Desktop relaunch is driven purely by the child exit event (session-launcher.ts:721), and a project switch uses a fresh port. For the relaunch never to happen, rsession itself must never have exited.
    • Server mode wedges identically for a complementary reason: a not-yet-exited rsession still holds its local-stream listening socket, so the proxy's connect() succeeds (kernel backlog), SessionUnavailable recovery never fires, no new session is launched, and the proxied request has no deadline (ServerSessionProxy.cpp).

    Every wait in rsession's shutdown sequence is nominally bounded (stopAgentSync <= 10s in SessionAssistant.cpp:615, the 1s grace loop in SessionChat.cpp:6388, 1s supervisor wait in SessionMain.cpp:1480) -- EXCEPT that the assistant/chat wait loops pump module_context::onBackgroundProcessing(false) and r::session::event_loop::processEvents() on every iteration. That dispatches the full background machine (supervisor poll, file monitor, every module's background handler, scheduled commands, arbitrary R callbacks) in the middle of teardown. Any blocking item in those queues wedges the loop forever, silently (all progress logging on these paths is DLOG). This is the only unbounded path, and it is only reachable when an agent/backend is running at shutdown -- which matches the trigger timeline below.

    Why it started when it did

    Fixes in flight

    1. e2e: keep the assistant provider off outside the @chat/@ai suites, so unrelated tests stop restarting sessions with a live agent (also removes ~2 agent start/stop cycles of overhead per restart).
    2. Product: during session shutdown, make the assistant/chat stop-waits pump only processSupervisor().poll() (all they need to observe the reap) instead of the full background-processing machine + R event loop.
    3. Product: escalate to SIGKILL / group kill when the agent survives the grace period (core::system::terminateProcess is SIGTERM-only, and terminateAllChildProcesses is off by default in the session).
    4. Desktop: a new session that dies during a project switch currently hangs silently because workbenchInitialized is stale-true and suppresses the launch error page (session-launcher.ts:458); reset it when relaunching.

    Worth a follow-up look (not in this PR): the server session proxy never sets a request deadline, and the local-stream acceptor lacks FD_CLOEXEC (an orphan inheriting it can starve session relaunch indefinitely); the Windows acceptor handle is similarly inheritable (bInheritHandles = TRUE with no SetHandleInformation on the acceptor).

  2. self-assigned this
    on Jul 30, 2026
  3. kevinushey commented on Aug 12, 2026

    @kevinushey
    CollaboratorAuthor

    Update 2026-08-12: the wedge is still occurring after #18417 (merged Aug 4), now confined to linux-server. Fresh sweep of the PR-triggered e2e workflow (~150 runs):

    date (UTC) run job hang point
    2026-08-11 23:40 31547344591 (PR #18521) linux-server (2) project_trust_dialog:358, after project create
    2026-08-11 23:36 31547120281 (PR #18520) linux-server (2) after project_editor_theme:255
    2026-08-11 19:34 31528533302 linux-server (2) after project_editor_theme:255
    2026-08-11 17:06 31515906367 linux-server (2) project_trust_dialog:358, after project create
    2026-08-11 06:50 31466565329 linux-server (2) project_trust_dialog:358, after project create
    2026-08-07 22:14 31223110969 linux-server (2) project_trust_dialog:358, after project create
    2026-08-05 20:03 31042248386 linux-server (2) project_trust_dialog:358, after project create
    2026-08-04 16:03 30927290169 windows (4) after project_editor_theme:255
    2026-08-03 18:49 30843028345 windows (4) after project_editor_theme:90
    2026-07-31 02:57 30600331378 linux-server (2) + linux-desktop after project_editor_theme:255 (both)

    Reading of the table:

    • The two Windows hits (Aug 3, Aug 4 16:03 UTC) started before fix session shutdown wedge with an active posit assistant #18417 merged (Aug 4 16:09 UTC), so they ran pre-fix builds. No desktop hang since -- the desktop-only leak guard plus the product fix appear to have closed the desktop path.
    • Every post-fix hang is linux-server shard 2, where the chat suites run earlier in the shard and the leak guard deliberately does not apply -- so the projects region still cycles ~30 session restarts with the assistant backend + agent live. Run 31547344591's journal confirms agent churn (repeated Agent process exited with status 143, keytar errors) in that worker's sessions right up to minutes before the wedge.
    • Notably, the journal shows none of fix session shutdown wedge with an active posit assistant #18417's new did-not-exit WARN lines during the wedge window, and rserver.log's mtime freezes at exactly the hang start. So the remaining server wedge either bypasses the assistant stop-waits that fix session shutdown wedge with an active posit assistant #18417 bounded, or is a different blocking point in the same shutdown/relaunch window. The July follow-ups (no deadline on the proxied session request; the local-stream acceptor lacking FD_CLOEXEC) remain open and are still the mechanism by which a not-yet-exited session black-holes the client indefinitely.

    From the one artifact the kill leaves behind (error-context.md on 31547344591): the test hit its 120s timeout and Tearing down "perTestReset" exceeded the test timeout -- the teardown's first step is an unbounded page.evaluate (drainClientExceptions), so once the page is stuck on the never-answered navigation, setup/teardown stages silently stack past the 300s heartbeat and the shard dies with no blob report, no trace (trace: 'off'), and no attachments.

    Harness mitigations going up in a PR shortly:

    1. Extend the assistant leak guard to spawned-server workers (safe: the CI spawn path gives each worker its own config home; only an external PW_RSTUDIO_SERVER_URL server shares prefs across workers, and that path stays excluded). This removes the remaining wedge trigger from the projects region on the affected shard.
    2. Bound the page-touching work in the per-test fixture and session shutdown with explicit deadlines, and on a wedged page capture protocol-level diagnostics that need no JS context (page.url() distinguishes a never-committing navigation from a frozen renderer; a CDP screenshot; both attached to the failing test). A wedge then becomes one fast, well-diagnosed test failure -- Playwright restarts the worker and the rest of the shard survives with its report intact, instead of a heartbeat SIGKILL taking the whole shard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions