Skip to content

Support non-buffered Server-Sent Events (SSE) responses in the Node.js SDK #18870

@ivan-jimmai

Description

@ivan-jimmai

Problem Statement

We operate a real-time AI chat platform (LibreChat-based) that streams LLM responses to clients using Server-Sent Events (SSE).

When the Sentry Node.js SDK (@sentry/node) is initialized, SSE responses stop streaming incrementally and instead appear to be buffered, causing the client UI to hang or fail to display tokens in real time.

Image

If Sentry initialization is removed entirely, SSE streaming works correctly.

We have confirmed:

  • The issue affects Express-based SSE endpoints
  • It occurs even when streaming routes are fully excluded from:
    Transactions
    Spans
    Events
    Profiling
  • The behavior suggests response buffering occurs before route-level filtering is applied
    This makes it currently impossible to use Sentry in production for applications that rely on long-lived SSE connections (e.g., AI token streaming).

Solution Brainstorm

Potential approaches that would enable safe SSE support:

  1. Opt-out of response buffering
    A global or per-route option to disable any response buffering or wrapping behavior in the Node SDK.
  2. SSE-aware HTTP instrumentation
    Detect Content-Type: text/event-stream and bypass any logic that intercepts or delays writes to res.
  3. Dedicated streaming-safe integration
    A lightweight HTTP integration mode for long-lived streaming responses that:
    - Captures errors only
    - Avoids transaction lifecycle tracking tied to response completion
  4. Official best-practice guidance
    Document a recommended pattern for monitoring SSE / AI streaming endpoints without breaking real-time delivery.

Additional Context

  • Stack: Node.js + Express
  • Streaming protocol: Server-Sent Events (SSE)
  • Use case: Real-time AI / LLM token streaming
  • Related discussion: Performance Monitoring for Web Streams (Response API) #9633
  • We attempted extensive route exclusions (ignoreTransactions, beforeSend, beforeSendTransaction, shouldCreateSpanForRequest) with no success, indicating buffering happens prior to those hooks.

This issue significantly limits Sentry adoption for modern AI platforms where streaming is a core requirement.

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions