Skip to content

fix(cart): add WebSocket heartbeat pings, exponential reconnect, and eliminate 5s GET polling - #31

Open
HimanM wants to merge 1 commit into
masterfrom
fix/cart-ws-heartbeat
Open

fix(cart): add WebSocket heartbeat pings, exponential reconnect, and eliminate 5s GET polling#31
HimanM wants to merge 1 commit into
masterfrom
fix/cart-ws-heartbeat

Conversation

@HimanM

@HimanM HimanM commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary of Changes

1. 💓 WebSocket Heartbeat Pings (25s Interval)

  • Periodically sends {"type": "ping"}\ across the cart WebSocket to keep the TCP connection alive through Nginx, Cloudflare, Vercel, and cloud proxies.
  • Prevents cloud firewalls and reverse proxies from dropping idle sockets after 30–60 seconds of inactivity.

2. 🔄 Smart Exponential Auto-Reconnect

  • Replaces the legacy fallback with an exponential backoff reconnect loop (1.5s, 3s, 6s, max 10s).
  • Automatically queries and updates cart state on reconnection to guarantee 100% data consistency.

3. 👁️ Tab Focus Revalidation

  • Automatically checks WebSocket connectivity and re-verifies cart state when the user focuses back into the browser tab.

4. 🚫 Eliminated 5-Second HTTP GET Polling Spam

  • Removed the continuous \setInterval(fetchCart, 5000)\ polling loop that caused recurring \GET /api/cart/sess-...\ requests in production network tabs.

Validation


  • pm run test:cart-revision: Passed (100%)

  • pm run test:recent-carts: Passed (100%)

  • pm run test:session-store: Passed (100%)

  • px next build: Compiled with 0 errors

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
kapruka-mcp-agent Ready Ready Preview Aug 17, 2026 10:13am

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