Skip to content

fix(settings): keep a setting changed back mid-save or just before a reload - #2747

Merged
devswha merged 1 commit into
mainfrom
fix/flaky-settings-unload
Nov 4, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/flaky-settings-unload

Conversation

@devswha

@devswha devswha commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Summary

scripts/settings-unload-regression.ts:42 timed out on PR CI (#2732, #2735). It reproduces on origin/main in isolation, so it is not only load: three causes stacked up.

  1. Product (preferencesSync.ts takePreferences): while a save was in flight, a value changed back here was measured against the old baseline, not against the change on its way. Turning a switch on, then off before the server's answer, made that answer (on) overwrite the local off. The muted panes already compared against the in-flight change; settings and pins now do too.
  2. Product (reload): Chromium sometimes drops the keepalive PUT /api/preferences sent at pagehide during a reload. A Chromium net-log of a failing run shows fetch was called (keepalive) but no request ever reached the network stack. The unsent change is now also left in sessionStorage; the reloaded tab treats each value still held as it went as its own edit and sends it again, but only when the server's revision has not moved past what the leaving page knew (a newer save from another browser wins).
  3. Test: line 41 passed an async predicate to page.waitForFunction; the returned Promise is truthy, so it never waited. It now waits on the server's event stream for the document holding the last value (bounded 5s, no fixed sleep).

Validation

  • Failing-first: the new takePreferences unit test and the new hook test ("the reloaded page sends it again") fail on origin/main's preferencesSync.ts and pass with the fix.
  • bun test src/lib/preferencesSync.test.ts src/lib/preferencesSync.hook.test.ts: 70 pass.
  • Browser regression on a built bundle, isolated server (mkdtemp state, port 0): before the fix about 9/64 failed at 8 parallel; after it 64/64 at 8 parallel and 96/96 at 12 parallel.
  • bun run check fast: ok (typecheck, build, 11077 unit pass).
  • Not run: bun run check full (CI runs it).

@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between cf40bb0 and 06149e8.

Files selected for processing: 5
  • changelog.d/settings-kept-across-quick-reload.md
  • scripts/settings-unload-regression.ts
  • src/lib/preferencesSync.hook.test.ts
  • src/lib/preferencesSync.test.ts
  • src/lib/preferencesSync.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@devswha

devswha commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

Merge note: merged on the omo review (CLEAR at this head), Codex Terra (no HIGH; reproduced findings fixed, the rest listed in the PR comments) and green checks. CodeRabbit did not review this head (rate-limited or skipped).

@devswha
devswha merged commit e634acf into main Nov 4, 2026
15 checks passed
@devswha
devswha deleted the fix/flaky-settings-unload branch November 4, 2026 14:29
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