Skip to content

[BUG] Server-Sent Events endpoint can generate excessive database load because each connection continuously polls without connection limits #1752

@Ridanshi

Description

@Ridanshi

Bug Summary

Each active SSE connection starts a recurring polling loop that performs database queries every few seconds.

There is currently no per-user connection limit, allowing a single authenticated user to create significant database load.

Describe the bug

The SSE endpoint creates a polling interval for every active connection.

Each interval repeatedly queries application data for the lifetime of the connection.

Multiple browser tabs, refresh loops, or automated clients can create many concurrent polling streams.

Because connection count is not restricted, database activity scales linearly with the number of open connections.

To Reproduce

  1. Authenticate normally.
  2. Open multiple browser tabs that connect to the SSE endpoint.
  3. Observe multiple concurrent SSE connections.
  4. Monitor database activity.
  5. Observe repeated query execution for each connection.

Expected behavior

The system should limit concurrent SSE connections per user or use a more efficient subscription model.

Actual behavior

Every connection creates an independent polling loop.

Additional context

Affected file:

src/app/api/stream/route.ts

Potential impact:

  • excessive database usage
  • degraded application performance
  • unnecessary resource consumption
  • increased operational costs

This issue becomes more noticeable under heavy dashboard usage or multi-tab sessions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions