Skip to content

RR7 + AI SDK + Sentry, consumed stream by Sentry leads to AI SDK failure result.consumeStream is not a function #17593

@w00fz

Description

@w00fz

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react-router

SDK Version

10.11.0

Framework Version

React 19.1.1, React Router Framework 7.8.2, AI SDK 5.0.39

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://github.com/w00fz/rr7_aisdk_sentry

Steps to Reproduce

  1. Clone the repository

  2. Create a .env file in the root with your OpenAI API and Sentry DSN keys:

    OPENAI_API_KEY=sk-...
    SENTRY_DSN=https://...
  3. Install dependencies with npm install

  4. Run the development server with npm run dev and verify everything works as expected. Simple chat input should stream back responses from the AI.

  5. Build the production version with npm run build

  6. Start the production server with NODE_ENV=production PORT=5173 npm run start

  7. Open the app in the browser and try to use the chat input again. You should see the error messages mentioned above.

    Example error message from stream

    data: {"type":"start","messageId":"34d1d9d5-74fc-4913-ac03-e9b7f8485faa"}
    data: {"type":"error","errorText":"result.consumeStream is not a function"}
    data: [DONE]
    

Change the start command removing the instrumentation and you will see it working as expected.

Expected Result

Stream is captured by the telemetry, visible in Sentry and AI SDK continues streaming back to the client.

Actual Result

Stream is captured by Sentry but appears to be entirely consumed, leading to undesired errors. The error is then streamed back to the client:

  • result.consumeStream is not a function
  • result.toUIMessageStream is not a function

Metadata

Metadata

Assignees

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions