Skip to content

fix(inbox): a closing tab no longer counts itself again after pagehide (notify_reach e2e) - #2250

Merged
backnotprop merged 5 commits into
mainfrom
fix/e2e-shared-events-notify-reach
Oct 28, 2026
Merged

backnotprop merged 5 commits into
mainfrom
fix/e2e-shared-events-notify-reach

Conversation

@backnotprop

@backnotprop backnotprop commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

inbox-shared-events.spec.ts "notify_reach follows the tabs" failed on #2242 and #2219 with Expected: 1, Received: 2 after the leader closes. It is a real race in the product, not a test timing problem. It is present since the shared stream landed (612ef88) and is not a regression from #2234.

Cause. At pagehide a tab sends gone and steps down, but its scripts still run for a moment. When the closing tab led, the next leader's announcement and its relayed hello reached it there. Each sent POST /api/inbox/window with served_by set to the next leader, which clears gone on the server. If that late report lands after the next leader's lock-watch gone, the closed tab stays counted for as long as the new leader's stream is open.

A server trace on CI (diagnostic commit, since reverted) shows the window: leave from the old leader, then report from the same window 5 ms later, then leave again from the new leader 37 ms later. Here the order was benign. In the failed runs it was reversed.

Fix. sharedEvents.ts: a tab that said gone at pagehide reports nothing (onConnect from a new leader or a relayed hello) until a pageshow brings it back from the back/forward cache. The e2e test is unchanged.

Evidence.

  • New unit test: a leader still running after its pagehide. It fails before the fix (3 reports instead of 1) and passes after. The bfcache test now also checks that nothing is reported between pagehide and pageshow.
  • bun test packages/inbox/: 469 pass.
  • The e2e test with --repeat-each 20 on the compiled binary: 20/20 pass. The whole shared-events file: 12 pass, 2 skipped as designed.

backnotprop and others added 4 commits October 27, 2026 14:20
…ents e2e

The notify_reach test (inbox-shared-events.spec.ts) fails on CI with
windows 2 after its 17 s hold, and does not reproduce on macOS or in a
Linux container. This commit only collects evidence from GitHub's runner:
the Inbox traces each window change (PLANNOTATOR_E2E_WINDOWS_TRACE, set by
the shared-events world only), the test records each tab's requests and the
count over time into the proof artifact, and the workflow runs the file 8
times before the full proof. It is reverted before review.
A closing tab still runs for a moment after pagehide. When it led, the next
leader's announcement and its relayed hello reached it there, and each sent a
window report (served_by the next leader). That report clears `gone`; landing
after the other tab's lock-watch `gone`, it left a closed tab counted for as
long as the next leader's stream stayed open. This is the notify_reach e2e
"Expected 1, Received 2" after the leader closes.

Now the tab reports nothing from pagehide until a pageshow brings it back.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@backnotprop backnotprop changed the title test(inbox): fix the notify_reach shared-events e2e flake fix(inbox): a closing tab no longer counts itself again after pagehide (notify_reach e2e) Oct 27, 2026
@backnotprop
backnotprop marked this pull request as ready for review October 27, 2026 20:01
…r changes

Guards the pageshow line that clears the post-pagehide silence; the header comment now names that silence.

Co-Authored-By: Claude <noreply@anthropic.com>
@backnotprop
backnotprop merged commit 1c8d576 into main Oct 28, 2026
39 of 41 checks passed
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.

1 participant