Skip to content

Harden realtime controls, endpoints, and lifecycle - #425

Open
terngunan wants to merge 1 commit into
Refract-Protocol:mainfrom
terngunan:feat/realtime-safety-issues-272-275
Open

terngunan wants to merge 1 commit into
Refract-Protocol:mainfrom
terngunan:feat/realtime-safety-issues-272-275

Conversation

@terngunan

Copy link
Copy Markdown

Summary

Adds runtime realtime controls and hardens the browser connection surface. Realtime endpoints now derive from one API URL helper used by the transport guard and report-only CSP. The client checks a remotely served control document before opening and before reconnecting, closes active sockets and clears subscriptions when disabled, and keeps the trip latched. A lifecycle adapter pauses sockets on hidden/pagehide/freeze and resumes on visible/pageshow/resume. The supported API is exposed through @/lib/realtime with a lint boundary.

Validation

  • Realtime-focused Vitest: 8 passed.
  • ESLint on changed realtime/provider files: passed with the repository's pre-existing no-restricted-syntax rule disabled.
  • Generated CSP header and git diff --check: passed.
  • Full npm run typecheck, npm run lint, and npm test remain blocked by existing repository failures: malformed JSX in src/app/cover/page.tsx, existing lint violations, and Vitest configuration/dependency issues (20 suites fail; unrelated passing tests include 48 passed).

Operational follow-up

The production /realtime-control.json must be served through the backend/CDN with a five-second maximum cache lifetime and purge support; coordinate that endpoint with refract-backend/on-call. This repo has no outbound realtime mutation queue, cross-tab leader-election lease, or existing realtime-consuming REST hooks, so this change cannot flush queued mutations/relinquish a leader role or demonstrate an app-level REST fallback integration. The new topic hook exposes best-effort updates and clears them on disable/lifecycle suspension; current application consumers should continue using REST as their source of truth.

Closes #275
Closes #274
Closes #273
Closes #272

@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

@terngunan Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant