Skip to content

Stream-driven live updates, shared freshness reads and ETag/304 for console reads - #72

Merged
shashikanth-gs merged 3 commits into
mainfrom
claude/bold-planck-3q0buf
Oct 22, 2026
Merged

shashikanth-gs merged 3 commits into
mainfrom
claude/bold-planck-3q0buf

Conversation

@shashikanth-gs

Copy link
Copy Markdown
Member

What changed and why

The console polled task-views, decisions and notifications every 5 seconds per tab on top of the SSE signal, and each open stream read the freshness token from the database every 500 ms. Both costs grew with the number of open tabs.

  • Client: removed the fixed 5-second poll loops. task-freshness polls (5–7.5 s, jittered) only while the stream is unavailable, stalled (no frame for 20 s) or failing to reconnect (5 s). Focus and signal refetches stay.
  • Server: CoalescedFreshnessReader shares token reads between streams, so the database sees at most one read per organization per 400 ms per web process. Stream lifetime is now randomized (40–55 s) so streams opened together (for example after a rollout) do not reconnect together.
  • Conditional reads: task-views, decisions and notifications send a weak body ETag and answer 304 to If-None-Match. Responses stay no-store; the client revalidates from tab memory, so the browser stores nothing, and skips re-rendering on 304.
  • Docs (durable tasks, workers, HTTP API, production deployment incl. multi-replica notes, console guide) and CHANGELOG.md updated.

Remaining work is tracked in #71 (skipping the query on unchanged reads, per-resource invalidation, LISTEN/NOTIFY, load numbers).

How it was verified

  • npm run lint, npx tsc --noEmit, npm test (624 tests), npm run build: pass.
  • npm run test:http: all scripts pass, including a new 304 check on /api/task-views.
  • freshness.db.test.ts on PGlite: pass.
  • Not run: the full npm run test:db, db:migrate and db:schema:check (no code in this change touches them), and nothing against a real PostgreSQL or multiple replicas.

Checklist

  • Focused change, with tests in the same change
  • npm run check passes (the part I could run is listed above)
  • Docs updated for the behavior you changed
  • Security-relevant changes update docs/security/threat-model.md (not applicable: responses stay no-store, nothing is written to browser storage)
  • User-visible changes are in CHANGELOG.md

Generated by Claude Code

…er freshness reads

Client: remove the fixed 5s poll loops; task-freshness polls (with jitter) only
while the SSE stream is unavailable or stalled.
Server: coalesce freshness token reads per organization per process so open
streams share database reads, and jitter stream lifetime to avoid synchronized
reconnects.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uu9rHW673neRB1LQgE3N1k
task-views, decisions and notifications return a weak body ETag and answer 304
to If-None-Match while staying no-store. The client revalidates from tab memory
(nothing is written to browser storage) and skips re-rendering on 304.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uu9rHW673neRB1LQgE3N1k

Copy link
Copy Markdown
Member Author

CI on the latest head: verify (full npm run check with PostgreSQL), package and platforms (macos-latest) pass. platforms (windows-latest) fails, but not because of this PR. It is the informational job (continue-on-error: true) and it fails the same way on main (run 39770353338, same step). Two Windows-only test assertions use / path literals: bin/launcher.test.mjs (resolveDataDir, expects /a, gets D:\a) and src/server/runtime/identity.test.ts (the route scan's auth/callback/route.ts exclusion). Nothing here touches either. Merging on the strength of verify.


Generated by Claude Code

@shashikanth-gs
shashikanth-gs merged commit 17bd556 into main Oct 22, 2026
3 of 4 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.

2 participants