-
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
SSG doesn't work for 404 error pages in Vercel environment when using getInitialProps on _app #19849
SSG doesn't work for 404 error pages in Vercel environment when using getInitialProps on _app #19849
Comments
There seem to be a lot of issues when using SSG (getStaticProps) with custom 404 pages in general (not only using getInitialProps in _app). @vajajak I might suggest editing the title of this issue to reflect that. In my case I'm not using getInitialProps in _app. I'm just trying to use getStaticProps with my custom 404 page (
Number 2 (above) is a real issue for me because my |
@vajajak I'm curious what error is being logged if you click "check the logs" on the NO_RESPONSE_FROM_FUNCTION error page... |
After working around the file read error, I found that the 404 page |
Hey @zenflow, thanks for commenting on my issue. I'm glad I'm not the only one who's experiencing such an issue.
|
@vajajak Yup, that's exactly it. I worked around this issue by using dynamic import (e.g.
Hmm.. that's strange. You are aware that for the error log to be displayed, the "Realtime Logs" screen has to be open when the error is generated, right? If you get an error and then open up the Realtime Logs, you won't see that past error. |
@zenflow Yup, I am aware that the logs page needs to be open. It's possible I accidentaly looked at a different deployment. I'm still not really sure what is causing the NO_RESPONSE_FROM_FUNCTION errors so I'm not sure how to reproduce it again right now (sometimes it just runs with this strange behavior described in my original bug report and sometimes returns the error). It's getting really late here so I'll try to reproduce it tomorrow and seek the logs again, and I'll let you know. |
Hey @zenflow and sorry for the late response. |
@vajajak Hmm without knowing the details of your project, I don't really have any guesses as to why your cms query behaves differently/strangely in this case. |
@vajajak Since we have narrowed in on the issue a little more, maybe the title of this issue should be updated, if only to get the proper attention?
|
Hi, this should now be updated to only run |
Hey, @ijjk. |
@vajajak can you provide a link to a repo/deployment where this is still occurring? If you are using |
@ijjk Here you go: https://zsjaklysa-27h00ad7a.vercel.app/_src. |
We've been struggling with the same issue and I also get these errors as soon as I include a |
Thanks for the repo with the reproduction, I tracked this down and opened a follow-up PR here that should address the remaining aspect of this. I will update here when this is published |
This is a follow-up to #5618 ensuring the 404 route is pointing to the static 404 output correctly when `_app.gip` and getStaticProps in `/404.js` is used ### Related Issues Fixes: vercel/next.js#19849 #### Tests - [ ] The code changed/added as part of this PR has been covered with tests - [ ] All tests pass locally with `yarn test-unit` #### Code Review - [ ] This PR has a concise title and thorough description useful to a reviewer - [ ] Issue from task tracker has a link to this PR
@ijjk The PR seems to be merged now and the issue has been closed once again. Yet, I'm still getting the same issue. To give a little more insight into what I'm actually doing to test this and how I have discovered this issue:
You can actually try this yourself in my example. Again, this is the latest version: https://zsjaklysa-8bk643bqs.vercel.app/_src
Thank you for your effort, I hope this gets resolved soon :) |
@vajajak the PR isn't available instantly when merged, it needs to be published to stable before it's available. I said I'd update here when it's available as the PR being merged doesn't mean it's available. I just published this change so it should now be available |
@ijjk Got it. I apologize for my impatience :). |
Great to hear that it works better. It unfortunately don't work for me, same error in the Vercel build logs. I tried the "Rebuild" button and I also tried to force a new build by re-pushing the commit. Here's the latest failing build: https://vercel.com/otovo/storefront/8gqzoyv2j Something I miss, @ijjk ? |
@kmkr this issue isn't related to a build-time error, this prevents the 404 |
@ijjk Thanks for fixing this! |
Ok. I must have misunderstood the thread, sorry. This change consistently triggers the failing build: And the logs don't help me much:
I'll try to work on that and will let you know if/when I have something. |
This is a follow-up to vercel/vercel#5618 ensuring the 404 route is pointing to the static 404 output correctly when `_app.gip` and getStaticProps in `/404.js` is used ### Related Issues Fixes: vercel/next.js#19849 #### Tests - [ ] The code changed/added as part of this PR has been covered with tests - [ ] All tests pass locally with `yarn test-unit` #### Code Review - [ ] This PR has a concise title and thorough description useful to a reviewer - [ ] Issue from task tracker has a link to this PR
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. |
This is a follow-up to vercel/vercel#5618 ensuring the 404 route is pointing to the static 404 output correctly when `_app.gip` and getStaticProps in `/404.js` is used ### Related Issues Fixes: vercel/next.js#19849 #### Tests - [ ] The code changed/added as part of this PR has been covered with tests - [ ] All tests pass locally with `yarn test-unit` #### Code Review - [ ] This PR has a concise title and thorough description useful to a reviewer - [ ] Issue from task tracker has a link to this PR
This is a follow-up to vercel/vercel#5618 ensuring the 404 route is pointing to the static 404 output correctly when `_app.gip` and getStaticProps in `/404.js` is used ### Related Issues Fixes: vercel/next.js#19849 #### Tests - [ ] The code changed/added as part of this PR has been covered with tests - [ ] All tests pass locally with `yarn test-unit` #### Code Review - [ ] This PR has a concise title and thorough description useful to a reviewer - [ ] Issue from task tracker has a link to this PR
Bug report
SSG doesn't work for 404 error pages in Vercel environment when using getInitialProps on _app
Describe the bug
Since there is still no support for getStaticProps on _app, I'm forced to keep using getInitialProps on _app to fetch common data for shared components (header, footer, seo, ...). Up until this point, I had no problems with this approach since I'm using getStaticProps to fetch data in all of my pages, and this does not opt-out of SSG. So only downside is that my website cannot use automatic static optimization.
However, today I noticed that when I go to page that does not exists and I get redirected to a 404 error page, I see changes in header that were made after the build. What is even more strange is that even when I clear all of my cache, on all subsequent requests to this page, changes in header are no longer reflected. But they still are reflected on 404 pages that i didn't access yet (but also only on the first access). The way it works closely resembles how Incremental Static Generation works.
It is important to note that I'm returning an empty getStaticProps in this page also, since I want the 404 error page to be also able to utilize SSG (since I'm using getInitialProps on _app and this is not automatic). (See screenshots below)
When seeing the build log, I get a full dot next to the 404 page meaning the page is statically pre-generated.
When running
npm run build
andnpm run start
on localhost, this issue does not occur. Not even when exporting to serverless environment (target: 'serverless' in next.config). But once I push the project to Vercel, the problem arises. From what I have discovered during my research, this bug is exclusive to Vercel environment.To Reproduce
Expected behavior
I expect the page to be statically generated since that is what I'm seeing from the build output.
Screenshots
Custom 404:
Build output:
System information
Additional context
During my research I also discovered that getStaticProps is not passing data to custom 404 component. I don't know if that's intentional. I didn't find it mentioned anywhere in the documentation though.
The text was updated successfully, but these errors were encountered: