sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Not working from Next.js middleware (edge runtime) when not using src folder

Open YoonIN opened this issue 1 year ago • 3 comments

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

I created two situations in the monorepo.

  1. nextjs project without src
  2. nextjs project with src

When both captureException and captureMessage are executed in middleware, they do not work in projects without src, but work in projects with src.

According to the issue in that link, it says that the issue has been resolved, but is the issue not resolved?

This link here is my sample.

Expected Result

The middleware sentry must operate in both projects.

Actual Result

Sentry operates in middleware only for projects with src.

Product Area

Unknown

Link

https://github.com/YoonIN/next-middleware-test

DSN

No response

Version

No response

YoonIN avatar Apr 29 '24 08:04 YoonIN

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] avatar Apr 29 '24 08:04 getsantry[bot]

Routing to @getsentry/product-owners-issues for triage ⏲️

getsantry[bot] avatar Apr 29 '24 18:04 getsantry[bot]

Hello and thanks for writing! First, thank you for the reproduction repo 🙌🏻

I tested the examples and for me, only captureException was not showing up in Sentry when using next dev. When creating a production build (next build and next start), everything was showing up in Sentry. image

In general, our SDKs are optimized for production builds. Can you tell me which command you were using when starting the application? And does using the production build for you also leads to issues not showing up?

s1gr1d avatar Apr 30 '24 12:04 s1gr1d

Sorry for the late reply.

As a result, it wasn't a problem with the src path like you said.

Our problem was that we had disabled the sideEffect.

Therefore, Sentry configuration files were treated as exceptions in the sideEffect rule.

package.json
...
"sideEffects": [
    "./sentry.client.config.js",
    "./sentry.edge.config.js",
    "./sentry.server.config.js"
  ],
...

Thank you for your reply.

YoonIN avatar May 07 '24 01:05 YoonIN

Were you able to run your example now? And did you have to add the files to sideEffects to make it work or is this the code example from where it did not work?

s1gr1d avatar May 07 '24 07:05 s1gr1d

Your example worked fine. In our production service, the problem occurred because we disabled sideEffects, and we had to exclude sentry files from sideEffects.

YoonIN avatar May 07 '24 07:05 YoonIN

This means you could fix it? :) I will close the issue then, but please reopen it if you still experience issues!

s1gr1d avatar May 08 '24 07:05 s1gr1d