Skip to content

Real-time webhook revalidation via Durable Objects and WebSockets#98

Merged
stylessh merged 2 commits intomainfrom
stylessh/sse-webhook-revalidation
Apr 13, 2026
Merged

Real-time webhook revalidation via Durable Objects and WebSockets#98
stylessh merged 2 commits intomainfrom
stylessh/sse-webhook-revalidation

Conversation

@stylessh
Copy link
Copy Markdown
Owner

Summary

  • Replaces the one-shot polling system (useGitHubSignalRefresh + server function) with a persistent WebSocket connection backed by a Cloudflare Durable Object (SignalRelay)
  • When a GitHub webhook arrives, signal keys are broadcast to all connected clients via the DO, and matching React Query caches are invalidated instantly — no polling or hard refresh needed
  • Custom worker entry (entry-worker.ts) intercepts WebSocket upgrades before TanStack Start to ensure compatibility, with auth gating on the upgrade path
  • All list pages (pulls, issues, reviews, dashboard overview) and detail pages (pull, issue, review) subscribe to relevant signal keys for live updates
  • Removes the old useGitHubSignalRefresh hook, getGitHubRevalidationSignalRecords server function, and related types to consolidate on a single revalidation system

Test plan

  • Deploy to preview and verify WebSocket connects (check debug logs in console)
  • Trigger a webhook event (e.g. push, PR update) and confirm queries revalidate without manual refresh
  • Verify no disconnect/reconnect cycles during normal navigation between pages
  • Confirm tab visibility changes correctly pause/resume the WebSocket connection

Replace the one-shot polling system (useGitHubSignalRefresh + SSE endpoint)
with a persistent WebSocket connection backed by a Cloudflare Durable Object.
When a GitHub webhook arrives, the signal is broadcast to all connected clients,
which then invalidate only the matching React Query caches instantly.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 13, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
diffkit 1cf2e99 Apr 13 2026, 08:31 PM

Removes the visibility change listener that disconnected/reconnected
the signal stream on tab blur/focus, preventing missed webhook updates.
@stylessh stylessh merged commit b76e105 into main Apr 13, 2026
4 checks passed
stylessh added a commit that referenced this pull request Apr 18, 2026
* Add real-time webhook revalidation via Durable Objects and WebSockets

Replace the one-shot polling system (useGitHubSignalRefresh + SSE endpoint)
with a persistent WebSocket connection backed by a Cloudflare Durable Object.
When a GitHub webhook arrives, the signal is broadcast to all connected clients,
which then invalidate only the matching React Query caches instantly.

* Keep WebSocket connected when tab loses focus

Removes the visibility change listener that disconnected/reconnected
the signal stream on tab blur/focus, preventing missed webhook updates.
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