Skip to content

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

Description

@ashconnell
  • @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?

Activity

  1. ashconnell commented on Aug 23, 2021

    @ashconnell
    Author

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

  2. ashconnell commented on Aug 24, 2021

    @ashconnell
    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.

  3. floriangosse commented on Oct 4, 2021

    @floriangosse
    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.

  4. github-actions commented on Oct 25, 2021

    @github-actions
    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 🥀

  5. lobsterkatie commented on Oct 27, 2021

    @lobsterkatie
    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?

  6. nicmesan2 commented on Nov 15, 2021

    @nicmesan2

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

  7. github-actions commented on Dec 7, 2021

    @github-actions
    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 🥀

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions