Skip to content

ensure sendPing onCompleted fires exactly once - #17906

Merged
kevinushey merged 2 commits into
mainfrom
bugfix/sendping-oncompleted-17143
Jun 9, 2026
Merged

kevinushey merged 2 commits into
mainfrom
bugfix/sendping-oncompleted-17143

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Summary

In SessionOpener.sendPing(), the onCompleted callback was never invoked when the ping loop exhausted its maxRetries. The loop logged a warning and returned false without signaling completion, so the restart flow's onRestartComplete (ApplicationQuit) never ran:

  • suspendingAndRestarting_ stayed true permanently, suppressing nested restart detection.
  • RestartStatusEvent.RESTART_COMPLETED was never fired, leaving listeners in stale state.
  • The progress indicator was never dismissed.

While re-evaluating, the onFailure path had a related defect: it called onCompleted without marking the loop as delivered and kept returning true, so repeated ping failures could invoke onCompleted -- and re-fire RESTART_COMPLETED -- multiple times.

Fix

Make pingDelivered_ a single fire-once guard, set on all three exit paths (success, failure, retry exhaustion) before invoking onCompleted. This:

  • Calls onCompleted on retry exhaustion so the restart flow always completes.
  • Ensures onCompleted fires exactly once across all paths, including the case where a hung in-flight ping returns after exhaustion.

Testing

  • cd src/gwt && ant javac (clean compile).
  • No automated test: the loop is a Scheduler-driven RepeatingCommand against a live ping RPC, which is not readily exercised by the GWT unit suite. The retry-exhaustion path triggers only when a ping neither succeeds nor fails for the full retry window, which is difficult to reproduce deterministically.

Addresses #17143.

In SessionOpener.sendPing, onCompleted was never invoked when the ping
loop exhausted its retry limit, leaving the restart flow's
onRestartComplete unrun: suspendingAndRestarting_ stuck true,
RESTART_COMPLETED never fired, and the progress indicator never
dismissed.

The onFailure path also called onCompleted without marking the loop
delivered, so repeated ping failures could invoke onCompleted (and fire
RESTART_COMPLETED) multiple times.

Make pingDelivered_ a single fire-once guard set on all three exit
paths -- success, failure, and retry exhaustion -- so onCompleted runs
exactly once.

Addresses #17143.
@kevinushey kevinushey added this to the Blue Plumbago milestone Jun 9, 2026
@kevinushey kevinushey self-assigned this Jun 9, 2026
The flag now guards one-time completion across success, failure, and
retry-exhaustion paths -- not just a delivered ping -- so completed_
describes its role more accurately. Updates the related comments too.
@github-actions

github-actions Bot commented Jun 9, 2026 •

Copy link
Copy Markdown

🍎 macOS Desktop E2E · ARM64

✅ All tests passed!

████████████████████ 100% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
323 0 12 1
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · macos-26 ARM64 · commit b5516d6aede15d8e0bc0d25e0f31d4095ebbf4f1 · Run #155

@kevinushey
kevinushey requested a review from gtritchie June 9, 2026 16:22

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Is it worthy of a NEWS entry?

@kevinushey

Copy link
Copy Markdown
Collaborator Author

I think we can skip NEWS; this is a pretty edge-casey fit and finish sort of change. Belt and suspenders, if you will.

@kevinushey
kevinushey merged commit 2812621 into main Jun 9, 2026
10 checks passed
@kevinushey
kevinushey deleted the bugfix/sendping-oncompleted-17143 branch June 9, 2026 18:01
kevinushey added a commit that referenced this pull request Sep 18, 2026
* wait for a slow restart to answer before giving up on it

SessionOpener.sendPing ticked every 200ms and spent one of its 50 retries
on every tick, including ticks where a ping was already in flight and
nothing was sent. The budget was therefore ~10.2s of wall clock however
many pings were actually attempted, and when it ran out the loop marked
itself completed -- so the ping that did answer a moment later was
discarded by the completed_ guard and ConsoleRestartRCompletedEvent never
fired. A ping can stay unanswered for much longer than that: rserver
holds an RPC aimed at a session it is still relaunching, and the new
session then has to restore the workspace before it services RPCs.

A failed ping ended the wait outright too, so the retry that would have
reached the new session was never sent. That half dates to #17906, which
made onCompleted fire exactly once but also made the first failure
terminal, leaving maxRetries unused.

Budget the wait in wall-clock time instead (60s), wait for an outstanding
ping rather than spending the budget on ticks that send nothing, retry
after a failure, and announce the restart whenever a ping answers -- even
if the wait already timed out, since an answer means R really is back.
onCompleted still runs exactly once.

Without the event, Shell leaves the console unfocused with a stale prompt
and the Console pane keeps showing the previous R version. The e2e test
added in #18858 hit this on Server, where a restart takes 9-11s; it no
longer needs to hold the completion ping to keep the event alive.

Addresses #18870.

* bound how late a timed-out restart ping may announce

A ping that answers after the timeout still announces the restart, but
only within a 5s grace period: announcing refocuses the console, which
would otherwise pull the user away arbitrarily late.

Also drop the restartAnnounced_ guard, which one-ping-at-a-time already
made unreachable.

Addresses #18870.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants