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

Next.js Edge Runtime fetch tracing #6804

Closed
Tracked by #9620
lforst opened this issue Jan 16, 2023 · 3 comments · Fixed by #9504
Closed
Tracked by #9620

Next.js Edge Runtime fetch tracing #6804

lforst opened this issue Jan 16, 2023 · 3 comments · Fixed by #9504
Assignees
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Improvement

Comments

@lforst
Copy link
Member

lforst commented Jan 16, 2023

Problem Statement

The Next.js SDK currently doesn't trace fetch calls on the edge runtime:

  • No spans for outgoing requests
  • No trace headers on outgoing requests

Solution Brainstorm

A quick test showed that using our browser implementation to patch fetch works for local builds but doesn't on Vercel.

Potential solutions:

  • Find a solution to monkey patch fetch through collaboration with Vercel
  • Wrap individual fetch calls via a webpack loader + AST magic
@lforst lforst added Type: Improvement Status: Backlog Package: nextjs Issues related to the Sentry Nextjs SDK labels Jan 16, 2023
@zcarlson-gmgt
Copy link

@lforst - I'm curious about the scope of this issue. Does it cover Edge API routes not sending Sentry issues entirely? Your note about it working for local builds made me want to verify. Or is this a separate issue?

Example Repro Steps (repo link)

  • Setup a new Next.js starting project (ex. next@13.1.6)
  • Install @sentry/nextjs@^7.50.0
  • Switch the example api file over to Edge runtime (add the code below)
    export const config = { runtime: 'edge', }
  • Start project in dev mode (yarn dev)
  • Use Postman to send a GET request to http://localhost:3000/api/sentry-example-api
  • Error never shows up in Sentry
  • Remove the edge runtime config and re-test with Postman. Error shows up in Sentry as expected

Side note: The error does show up in Sentry when navigating to that url in a browser but I'm assuming that's because it's a client side error

@lforst
Copy link
Member Author

lforst commented May 3, 2023

@zcarlson-gmgt this issue is not related to what you think it is. This is about instrumenting fetch if called within an edge route.

As for your example: Edge error reporting currently doesn't work in dev mode. I could verify with your example that it does indeed work for prod builds.

@zcarlson-gmgt
Copy link

@lforst oh wow thank you! Glad it was simple!

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 Type: Improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants