Skip to content

tRPC server errors not sent from vercel deployment. Local works fine #17024

Closed

Description

@MathiasGruber

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

9.38.0

Framework Version

15.4.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://github.com/studie-tech/TheNinjaRPG

I believe the most relevant files are:

https://github.com/studie-tech/TheNinjaRPG/blob/main/app/instrumentation.ts
https://github.com/studie-tech/TheNinjaRPG/blob/main/app/sentry.server.config.ts
https://github.com/studie-tech/TheNinjaRPG/blob/main/app/src/app/api/trpc/%5Btrpc%5D/route.ts

Specifically, I have implemented Sentry.flush as I thought that was the most likely culprit, but to no avail.

Steps to Reproduce

Whenever I trigger an error in a tRPC endpoint on purpose, I get the error when working from local, but not when deployed on vercel. The full configuration can be seen here:
studie-tech/TheNinjaRPG

I'm not using environment variables for the DSN, which seems to be a common cause of this. I've gone through the entire setup of Sentry again.

This worked a few months ago when initially set up, but has since then been broken.

Expected Result

Expect similar behavior on local and vercel deployment

Actual Result

No errors reported from vercel

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 15, 2025
  2. s1gr1d commented on Jul 16, 2025

    @s1gr1d
    Member

    Hello, most often this can be solved by flushing (as you already tried). I also see that you tried another flushing approach in the latest commit which was just 3 hours ago (this issue is 16h old now). Did that work for you now?

    The reason for a need to flush is that the function may have a limited execution time and the error cannot be sent anymore. By awaiting a flush, the function executes a little longer.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 16, 2025
  4. MathiasGruber commented on Jul 17, 2025

    @MathiasGruber
    Author

    Nope, as you mentioned I tried a few different flusing methods, but to no avail.

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 17, 2025
  6. s1gr1d commented on Jul 18, 2025

    @s1gr1d
    Member

    We're gonna have a look at this!

    cc @chargome

  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 18, 2025
  8. 18 remaining items

  9. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 7, 2025
  10. chargome commented on Aug 8, 2025

    @chargome
    Member

    No sorry what I meant was to use the Next.js after hook. Missed the import in my snippet: import {after} from 'next/server'

  11. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Aug 8, 2025
  12. MathiasGruber commented on Aug 10, 2025

    @MathiasGruber
    Author

    Ah, okay, didn't know about that hook, I've updated:
    studie-tech/TheNinjaRPG@9da2a0f

    Result is the local still works, deployment on vercel does not.

  13. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 10, 2025
  14. chargome commented on Aug 11, 2025

    @chargome
    Member

    Thanks for confirming, this must be unrelated to flushing then which is strange. 🤔 We need to look into this in more detail.

  15. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Aug 11, 2025
  16. self-assigned this
    on Oct 21, 2026
  17. s1gr1d commented on Oct 21, 2026

    @s1gr1d
    Member

    The cause was that next build only picks up instrumentation.ts next to your app directory, so with src/app it must be in src/ (I see you already fixed that in your reprex).

    Locally it worked because dev also finds it in the project root. The SDK will warn about this at build time soon (#25603). Closing, but feel free to reopen if something still doesn't show up.

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

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions