Skip to content

fix(sync): stop firing a full Atlas sync on every message#61

Merged
Aayam Bansal (aayambansal) merged 1 commit into
mainfrom
fix/wallet-sync-throttle
Jul 5, 2026
Merged

fix(sync): stop firing a full Atlas sync on every message#61
Aayam Bansal (aayambansal) merged 1 commit into
mainfrom
fix/wallet-sync-throttle

Conversation

@aayambansal

Copy link
Copy Markdown
Member

Fixes #52.

getSession() rebuilt the session object with only api_key/user_id/device_name, dropping the two fields refreshIfStale() depends on: last_check_ts (probe TTL) and cached_v (version dedupe). So the TTL gate never passed and the version always looked changed — every message fired a /api/cli/sync/version probe plus a full background /api/cli/sync, each rewriting synced-env.json, openscience-synced.json, and the session file, and invalidating provider state. updateSession (getSession + spread + save) also erased whichever bookkeeping field it wasn't patching, which is why the probe's own timestamp never stuck.

The fix carries cached_v and last_check_ts through getSession(), which restores both the 10-second probe TTL and the version dedupe, and makes updateSession merges lossless.

Beyond the request storm itself, this shrinks the attack surface for #55 (a transient 403 during sync silently signs the user out): fewer syncs, fewer chances to trip it.

Regression test writes a session file with both fields and asserts getSession returns them; it fails on main and passes here. Full backend suite: 829 pass / 0 fail. Typecheck clean.

getSession() rebuilt the session object with only api_key/user_id/
device_name, dropping cached_v and last_check_ts. refreshIfStale() reads
both, so its TTL gate and version dedupe were dead code: every CLI
invocation and every processor iteration fired a /api/cli/sync/version
probe plus a full background /api/cli/sync, each rewriting synced-env
and session files. updateSession (getSession + spread + save) also
erased whichever bookkeeping field it wasn't patching.

Carry the two fields through getSession so the 10s probe TTL and the
version dedupe work as designed.
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openscience Ready Ready Preview, Comment Jul 5, 2026 10:58am

Request Review

@aayambansal Aayam Bansal (aayambansal) merged commit 5d13bb4 into main Jul 5, 2026
9 checks passed
@aayambansal Aayam Bansal (aayambansal) deleted the fix/wallet-sync-throttle branch July 5, 2026 11:04
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.

Wallet sync throttle is dead code: full Atlas sync fires on every message

1 participant