-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
DYNAMIC_SERVER_USAGE
in Next.js App Dir
#9290
Comments
Hey @EnriqCG, thanks for writing in! It makes sense for us to not capture this error if you're intentionally trying to create dynamic components. PRs are welcome if you would like to help fix this! Otherwise we can also take a look in a bit. |
Hm, I think this error has value and is actionable... I am not sure if we should ignore it. |
The action I took after being surprised by these errors showing up in Sentry (at runtime in my case) was to explicitly mark the affected pages as requiring dynamic rendering (
I'm curious about the value you see in highlighting these non-fatal errors, @lforst , I wouldn't say I'm an expert on this new app router world but it seems to be idiomatic to implicitly opt-in to dynamic rendering, as seen in the official documentation 🙂 |
@cysp I believe this is an error that is worth reporting. It is not idiomatic to have an app that throws this error at all. We should probably not report this error while building, but we should definitely report it when pages are regenerated (ISR) as it can lead to unexpected behavior. For anybody stumbling onto this, the SDK will not crash anything or block any builds. It just picks up an error that is emitted during build or while regenerating pages. |
IMO, the issue is that it emphasizes an error that is meant to be ignored during build time, but that should be interpreted as a real error if it happened at run time. I do want these errors to be thrown at run time since they indicate issues that need to be fixed. But, having a bunch created every time we build clogs up the error log and makes it difficult to identify real runtime ones if they sneak in. |
@justinpincar 100% agree. We'll stop reporting them during build. |
As a user, this is annoyin, glad there's a fix already :) when is this coming out? |
@pyrexfm It is already out! If you still see these errors in Sentry they are likely actual errors and you may want to fix them. |
@lforst I am still getting the error though. Funny thing is it was working. Then I made some change and tried to rebuild on the server and it failed. |
@ProfNuru I don't see Sentry anywhere in your project. |
@lforst apologies. I didn't quite understand above. How will Sentry help resolve it? |
Sentry will help you narrow down which components throw these errors are thrown in so you can go in and mark them as dynamic. |
@lforst My error occurs when I try to build. Sentry seems to only log error when running the application. |
@ProfNuru Correct. Sentry is not a tool to analyze your build errors. |
I have no idea how to begin trying to fix the error. All suggestions from my searches do not work. My error: |
@ProfNuru I believe you are in the wrong place to gain qualified information about dynamic server usage. The best place is probably the discussions section in the Next.js repository! https://github.com/vercel/next.js/discussions This repository here is for questions and issues related to the Sentry JS SDK. |
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
7.74.0
Framework Version
Next.js 13.5.3
Link to Sentry event
https://the-network-state-co-5d0b7f51d.sentry.io/issues/4554179142/?project=4505835380736000&query=is:unresolved&statsPeriod=14d&stream_index=0
SDK Setup
Steps to Reproduce
cookies()
orheaders()
to make a Server Component render dynamicallyExpected Result
It should not send
DYNAMIC_SERVER_USAGE
traces that don't prevent the build from succeeding to Sentry.I think this is a very similar issue to #7641 where Exceptions in Next.js are handled internally to create some kind of fallback behavior. In the case of
DYNAMIC_SERVER_USAGE
, it signals that the Server Component can't be pre-rendered at build time.Actual Result
Once the build completes, see the Sentry Issue dashboard with "Dynamic server usage: Page couldn't be rendered statically because it used
cookies
"The text was updated successfully, but these errors were encountered: