-
Notifications
You must be signed in to change notification settings - Fork 27k
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 10.0.8 attempts to generate static error pages despite _error
with getInitialProps
#22815
Comments
_error
has getInitialProps
_error
has getInitialProps
_error
with getInitialProps
Hi, it looks like If you are encountering errors from |
For me the issue is more than /404 page. The issue is that if you have _error, 404 or 500 pages, the build will try to run Her is a simple project that tries to produce the issue |
We have a custom server and it is responsible for:
All of the Express-to-Next transport is accomplished by appending data to the I understand why we have this issue with the build changes in 10.0.8 - Next's static build can't possibly know about the details of our custom server - but I wouldn't necessarily call this a bug, especially since Next explicitly supports custom servers. The errors are actually thrown in the It's possible that we could transition some of this to an _app-based gSSP approach, but that's not currently supported. Something like our dynamic configuration is basically only valid for its 15 minute window, so a statically generated version would be weird anyway. And I imagine that if I may have been too proscriptive in the initial bug description. Basically the problem is that we want to always avoid SSG for this app. That was previously possible through our current configuration. Supporting that combination going forward would be one solution. Another would be simply exposing a configuration flag that explicitly disables all SSG, which would probably be easier to support long-term without regressions. If I had to resort to using |
I agree. I'd go with opt-in or opt-out next config setting instead of going through the rabbit hole of guarding all SSG requests. |
I followed the |
I have only
At the errors stack I found your's sugestion message
Following this url https://err.sh/next.js/gssp-export I must remove Before 10.0.8 - all worked fine |
10.0.7 - works |
This ensures we don't export `/404` during the automatic static optimization during build when the `/404` isn't static and won't be used/copied to the final output. x-ref: #22815
The latest commit pushed in 10.0.9-canary.1 fixes the 404 issue, but I still have a similar issue with respect to
The response object in |
I am facing the same problem. Upgrading to 10.0.9-canary.2, the error with a Due to some incompatibilities with Webpack 5, in our application it is not possible to go back to v10.0.7. Has anyone found a workaround? Or it's just wait for a commit to resolve this issue? |
There's a PR open to fix this: #22887 |
This updates to not automatically export `/500` from `_error` if a custom `getInitialProps` is used since logic may be used inside of this method that causes the export to fail. Users can still opt-in to the static `/500` by adding a `pages/500.js` file. This also refactors checking `_app` for custom `getInitialProps` to outside of the static check loop to prevent a potential race condition where we could run this check multiple times un-necessarily. Fixes: vercel#22815
Great news! Now we just have to wait for a new version |
This should be updated in |
I upgraded to this version and now everything is working as it should. My task will not need to be blocked, thank you very much! |
Still seems to be somewhat of an issue at least in |
Verified this fix worked for us. Thanks for the patch! |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
10.0.8
What version of Node.js are you using?
12.13.0
What browser are you using?
All
What operating system are you using?
macOS
How are you deploying your application?
Own infra
Describe the Bug
We have an
_error
component withgetInitialProps
(as does our_app
component) and no/404
or/500
components, as we need dynamism on these routes for i18n, tracking, etc. Under 10.0.7, this correctly opted all error paths out of static optimization during build:Under 10.0.8,
next build
attempts to erroneously generate static pages, which fails because they rely on dynamism (specifically data collected from our custom server and transported into Next via thereq
object):I'm guessing this was introduced alongside the new static
/500
component introduction?Expected Behavior
next build
won't attempt to generate static pages for 404/500 paths when_error
hasgetInitialProps
defined and no static404
or500
components are definedTo Reproduce
Attempt to build a next app with
_error
withgetInitialProps
defined and no500
or404
componentsThe text was updated successfully, but these errors were encountered: