Skip to content

Document three e2e completion signals that pass vacuously - #18455

Merged
gtritchie merged 6 commits into
mainfrom
developer/document-e2e-completion-signal-gotchas
Aug 7, 2026
Merged

gtritchie merged 6 commits into
mainfrom
developer/document-e2e-completion-signal-gotchas

Conversation

@gtritchie

Copy link
Copy Markdown
Member

Adds three entries to the "Waits and markers that lie" section of the
rstudio-create-playwright-tests skill. No product change; guidance only, so no
NEWS entry and no associated issue.

Each of these was found the hard way while writing the regression tests for
#18444 (#18454): in every case a test passed while never exercising the code it
was written to guard.

  1. A console prompt does not mean R-side change detection has run. The
    session enqueues kConsolePrompt before calling onDetectChanges
    (SessionConsoleInput.cpp), so executeInConsole -- which resolves on the
    prompt counter -- returns before a plot raising the Plots pane, a package-list
    refresh, or a file change has been queued. A test that waits on the prompt and
    then measures asserts against the pre-effect state.

  2. Client state is pushed on a passive 5s timer. persistClientState() fires
    PushClientStateEvent with active=false, so ClientStateUpdater reschedules
    rather than nudging. A test that changes persisted state and reloads outruns
    the save and restores nothing. The entry gives the set_client_state
    waitForResponse predicate, and notes that all state values ship in one RPC,
    so the wait also gates state written by other components in the same push.

  3. window.rstudio.ready, not a pane selector, gates post-reload state.
    Workbench pane elements attach at construction, well before client state is
    applied, so waitForSelector('#rstudio_TabSet1_pane') returns while startup
    state handling is still pending -- including work deferred on a timer, such as
    PaneManager.ZoomedTabStateValue.onInit.

Each of these made a test in the #18444 work pass without exercising the code
it was written to guard:

- executeInConsole resolves on the console prompt, which the session enqueues
  before running change detection, so plot/package/file effects have not been
  delivered yet.
- Client state is pushed on a passive 5s timer, so a reload outruns the save
  and restores nothing.
- Workbench pane elements attach long before client state is applied, so a pane
  selector is not a gate for startup state handling.

No product change; guidance only.
@posit-snyk-bot

posit-snyk-bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gtritchie gtritchie added this to the 2026.09 (Autumn Hawkbit) milestone Aug 5, 2026
Both entries as written could still let a test pass vacuously, which is the
exact failure mode the section documents:

- The set_client_state gate only proved the RPC was sent. waitForResponse
  resolves on a rejected response too, and a failed RPC comes back HTTP 200
  with an error member (sendJsonRpcError goes through sendJsonRpcResponse),
  so response.ok() is not enough either -- the body has to be checked.
- window.rstudio.ready was described as gating post-reload state. On the
  re-join path a page.reload() takes it is set in initializeAgent(), which
  Application.java calls immediately before initializeWorkbench(), so it can
  be observed before PaneManager exists.

Split out the reason the second one matters: expect.poll returns on its first
passing sample, so it cannot assert that something never happens -- the
pre-condition state is the passing state and the poll is green before the bad
state arrives.

No product change; guidance only.
The entry said window.rstudio.ready can be observed before PaneManager is
constructed. It cannot. Application.java calls initializeAgent() and
initializeWorkbench() in one task, and WorkbenchScreen builds PaneManager
synchronously (paneManager_ = pPaneManager.get()), so the event loop never
yields in between -- an out-of-page observer only ever sees ready after the
panes exist.

The entry's conclusion is unchanged, because it does not rest on that claim:
ready still is not a state-applied gate, since startup work deferred to a later
task (scheduleDeferred, and timers like ZoomedTabStateValue.onInit's 200ms one)
is outstanding when it flips.
initializeWorkbench() returns early with a ReloadEvent when the UI-language
cookie, or on Electron the web-dialogs cookie, disagrees with its pref -- before
it constructs the workbench, and the reload it fires is delayed. ready is
already true at that point, so it can be observed with no panes at all.

The previous wording had swung too far the other way, claiming ready does mean
the panes exist. Neither direction is a safe thing to lean on; the element wait
belongs in the assertion.
Same facts, shorter sentences. These entries had grown long clauses and nested
asides across three revisions, which made them hard to read.

Entry 11 carried two independent reasons in one paragraph, so it now states
them as a list and puts the re-join detail after them, where it explains the
first reason instead of interrupting it.
Entry 9 said executeInConsole returns before change detection has queued
anything. That is only one of the possible outcomes. ClientEventQueue::add ends
with notify_all, so queueing the prompt wakes a waiting get_events poller before
onDetectChanges runs on the R thread -- but whether the poller drains first is a
thread race, so the change events may also be queued, or delivered, and merely
not rendered.

State the part that is always true instead: the prompt is ordered ahead of the
change-detection events and can reach the client first, so at the moment the
prompt counter advances the effect may be unqueued, undelivered, or unrendered.
The guidance is unchanged, and holds in all three cases.
@gtritchie
gtritchie merged commit 5f16769 into main Aug 7, 2026
6 checks passed
@gtritchie
gtritchie deleted the developer/document-e2e-completion-signal-gotchas branch August 7, 2026 21:41
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