Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@sentry/nextjs] api route transaction bleed still happening #3913

Closed
ashconnell opened this issue Aug 23, 2021 · 7 comments
Closed

[@sentry/nextjs] api route transaction bleed still happening #3913

ashconnell opened this issue Aug 23, 2021 · 7 comments
Assignees
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@ashconnell
Copy link

ashconnell commented Aug 23, 2021

  • @sentry/nextjs 6.11.0
  • Running Next.js as a regular node server (eg not Vercel lambdas)

Our infra pings our Next.js API Route GET /api/healthz before each deployment goes live.
For some reason, every event after this shows up in Sentry associated with this transaction.

It looks like domains were supposed to prevent this from happening (#3788 and #3574) but we're seeing it consistently.

Possibly related, to keep our files DRY we define our withSentry (amongst other things like auth etc) in a file that is imported and used by each API Route:

// shared/route.js
import { withSentry } from '@sentry/nextjs'

export function route(req, res) {
  return withSentry(async (req, res) => {
    // perform auth, log ip etc
  })
}
// api/foobars.js
import { route } from 'shared/route'

export default route(req, res) {
  res.status(200).send('Foobars')
}

Our code definitely returns a new instance of withSentry() but I wonder if domains are not able to clearly differentiate?

@ashconnell
Copy link
Author

I wonder if we should actually be using AsyncLocalStorage: https://nodejs.org/api/async_context.html

@AbhiPrasad AbhiPrasad added the Package: nextjs Issues related to the Sentry Nextjs SDK label Aug 23, 2021
@ashconnell
Copy link
Author

Just to confirm, I moved all my withSentry calls to explicitly wrap each API Route (instead of using a shared import) but this issue still happens.

@floriangosse
Copy link
Contributor

I can confirm that we've the same problem with the setup from the documentation:

  • Use withSentryConfig in next.config.js
  • Have sentry.client.config.js and sentry.server.config.js in projects root (next to next.config.js)
  • Use @sentry/nextjs across the application

One thing we don't do because it doesn't seem to be necessary is that we don't import @sentry/nextjs in our health check API route.

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@lobsterkatie
Copy link
Member

I suspect this bug that this fixes may be to blame: #4086. We should release a new version (which will be 6.13.4) in the next few days, which will include that fix. Once that happens, can you please let us know if you're still having problems?

@nicmesan2
Copy link

nicmesan2 commented Nov 15, 2021

Having the same issue here using the latest version 6.14.3. Any updates on this? @lobsterkatie

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2021

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
None yet
Development

No branches or pull requests

5 participants