Skip to content

[FEAT] : fixed Broken Real-Time SSE Dashboard Updates #3154

Open
hrshjswniii wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
hrshjswniii:feature/SSE-Dashboard-Updates
Open

[FEAT] : fixed Broken Real-Time SSE Dashboard Updates #3154
hrshjswniii wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
hrshjswniii:feature/SSE-Dashboard-Updates

Conversation

@hrshjswniii

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the Server-Sent Events (SSE) real-time dashboard notification system. It adds connection registration logic to the stream API route, refactors the socket registry to support multi-tab synchronization via Sets, and resolves a database UUID lookup mismatch in the GitHub push webhook handler.

Closes #3129

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • SSE Core Registry (src/lib/sse.ts):
    • Refactored sseConnections to map user UUIDs to a Set<ReadableStreamDefaultController> instead of a single controller. This supports multi-tab setups and prevents tabs from overriding or clearing active sockets.
    • Updated sendSSEEvent to push events to all active controllers in the user's Set and dynamically prune failed connections.
  • Stream API Router (src/app/api/stream/route.ts):
    • Registered the active stream controller in the user's sseConnections Set during stream startup.
    • Safely deleted the controller from the user's Set in closeStream(), cleaning up empty registry keys.
  • GitHub Webhook Handler (src/app/api/webhooks/github/route.ts):
    • Changed sendSSEEvent to dispatch push notification payloads using the resolved database user UUID (staleResult.userId) instead of the mutable githubLogin string.
  • SSE Unit Tests (test/sse-stream-route.test.ts):
    • Added test cases verifying stream controller registration on connection, cleanup on disconnection, and concurrent tab tracking.

How to Test

  1. Run the stream route tests:
    node node_modules/vitest/vitest.mjs run test/sse-stream-route.test.ts
  2. Verify that all 21 unit tests (including the 3 new connection lifecycle tests) pass successfully.

Expected result:
All tests pass cleanly.


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

Additional Context

  • The Set-based socket registry solves a key limitation of the original design where closing any browser tab terminated push events for all other active tabs.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts) type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) and removed gssoc26 GSSoC 2026 contribution labels Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

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

Labels

type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] : Broken Real-Time SSE Dashboard Updates

1 participant