Skip to content

[Bug]: Real-time SSE notifications fail silently in multi-instance/serverless deployments #1061

Description

@Shreya-nipunge

Bug Description

The real-time notification system uses an in-memory Map to store active Server-Sent Events (SSE) subscriber connections in src/lib/notifications/realtime.ts.

Because these connections are stored only in the memory of a single server instance, notifications published from another instance are not delivered to connected users when the application runs in a multi-instance or serverless environment.

This causes real-time notifications to fail silently depending on which instance handles the request.

Steps to Reproduce

  1. Deploy the application with multiple server instances or serverless workers.
  2. Open a notification SSE connection from a user on instance A.
  3. Trigger a notification event that gets processed by instance B.
  4. Observe that the connected user does not receive the notification.

Expected Behavior

SSE subscriber connections should work across multiple instances by using a shared mechanism such as Redis pub/sub, a database-backed event system, or another distributed messaging layer.

Actual Behavior

Notifications are only delivered when the publishing request and SSE connection are handled by the same server instance. Users connected to other instances receive no notification.

Screenshots

N/A

Environment

  • OS: Any
  • Browser: Any modern browser supporting SSE
  • Node.js version: Any supported version
  • Screen size: Desktop/Mobile

Console Errors

No visible client-side error. Notifications fail silently.

Additional Context

The issue is caused by storing active SSE connections in process memory. This approach works in a single-server environment but is unreliable in horizontally scaled or serverless deployments.

Metadata

Metadata

Labels

backendAPI routes, database, server logicgssoc'26GSSoC program issuelevel:advancedAdvanced level tasktype:bugBug fix

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions