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

Bug: loading dev card page from the user profile crashes #4108

Closed
nickytonline opened this issue Sep 18, 2024 · 23 comments · Fixed by #4158
Closed

Bug: loading dev card page from the user profile crashes #4108

nickytonline opened this issue Sep 18, 2024 · 23 comments · Fixed by #4158
Assignees
Labels

Comments

@nickytonline
Copy link
Member

nickytonline commented Sep 18, 2024

Going to the dev card page directly works, but if you click on the dev card button near the avatar on the user profile page, it crashes.

CleanShot 2024-09-18 at 08 17 58

CleanShot 2024-09-18 at 08 20 19

The user is null causing the crash.

@nickytonline nickytonline added 🐛 bug Something isn't working high-priority Work on these issues first labels Sep 18, 2024
@nickytonline nickytonline self-assigned this Sep 18, 2024
Copy link
Contributor

Thanks for the issue, our team will look into it as soon as possible! If you would like to work on this issue, please wait for us to decide if it's ready. The issue will be ready to work on once we remove the "needs triage" label.

To claim an issue that does not have the "needs triage" label, please leave a comment that says ".take". If you have any questions, please comment on this issue.

For full info on how to contribute, please check out our contributors guide.

@nickytonline nickytonline removed the high-priority Work on these issues first label Sep 18, 2024
@nickytonline
Copy link
Member Author

nickytonline commented Sep 18, 2024

This is still an issue, but it appears to only occur when running locally in dev mode. Beta and Prod are fine.

Also running npm run build;npm run start locally is all good, i.e. a prod build.

It should be sorted out still though as this make for poor DX if working on the user profile/dev card. The odd thing is this is a server-side prop so if it's set, which it does get set, it shouldn't be undefined when running client-side during hydration.

const username = context?.params?.username as string | undefined;
if (!username) {
return {
notFound: true,
};
}
const { data: userData, error } = await fetchApiData({
path: `users/${username}`,
pathValidator: () => safeParse(GitHubUserNameSchema, username).success,
});
if (error || !userData) {
return {
notFound: true,
};
}

@nickytonline nickytonline removed their assignment Sep 18, 2024
@Dun-sin
Copy link
Contributor

Dun-sin commented Sep 23, 2024

@nickytonline what do you want to do with this? should this still be debugged?

@nickytonline
Copy link
Member Author

It's, most likely related to React's strict mode which is on by default in Next.js. Feel free to dig into this.

@Dun-sin
Copy link
Contributor

Dun-sin commented Sep 24, 2024

It's, most likely related to React's strict mode which is on by default in Next.js. Feel free to dig into this.

Got it💪🏽

@Bashamega
Copy link
Contributor

Can I work on this?

@nickytonline
Copy link
Member Author

nickytonline commented Oct 1, 2024

For full info on how to contribute, please check out our contributors guide.

Please read the contributing guidelines if you'd like to work on this.

@Bashamega
Copy link
Contributor

.take

@Bashamega
Copy link
Contributor

For full info on how to contribute, please check out our contributors guide.

Please read the contributing guidelines if you'd like to work on this.

Thanks

@Bashamega
Copy link
Contributor

Bashamega commented Oct 1, 2024

Hello @nickytonline
I have tried to run it locally and go to the profile, I get this error:
image

Console:
image

Note: I have followed the steps

@nickytonline
Copy link
Member Author

@Bashamega, ensure you have latest of the beta branch. I just pulled down all the latest changes and I do not get the error you get, I get the original error still.

CleanShot 2024-10-01 at 13 24 10@2x

@Bashamega
Copy link
Contributor

@nickytonline on my side the profile page is not loading, so i can't click on the badge.

@nickytonline
Copy link
Member Author

Please ensure that you have the latest of the beta branch and that you've followed the steps in our README to get up and running locally. It definitely works locally (with the error mentioned in the issue) and it's working in our beta and production environment, so my guess is there is something not right in your local environment.

@Bashamega
Copy link
Contributor

Please ensure that you have the latest of the beta branch and that you've followed the steps in our README to get up and running locally. It definitely works locally (with the error mentioned in the issue) and it's working in our beta and production environment, so my guess is there is something not right in your local environment.

I have followed the steps in the readme.
I have ran:

npm ci
npm run dev

@nickytonline
Copy link
Member Author

nickytonline commented Oct 6, 2024

I'm not sure what the issue is. Can you open the project in GitHub CodeSpaces, and run the setup? I have a feeling it's something with your local environment, but I have no idea what at the moment. Even if you're on Windows, that type of error wouldn't be OS specific.

CleanShot 2024-10-06 at 10 54 30

@Bashamega
Copy link
Contributor

sure

@Bashamega
Copy link
Contributor

Thanks @nickytonline ,
It worked, i fix the issue now

@Bashamega
Copy link
Contributor

The problem is with the Link tag, the link tag doesn't make it a full reload, causing the getServerSideProps to not run. There are 2 options to fix this issue:

  1. Remove the Link tag and replace with window.location.href.
  2. Remove the getServerSideProps and write it in a useEffect.

@nickytonline
Copy link
Member Author

Glad things work for your environment now.

We want to keep the getServerSideProps, but I'm not sure a window.location.href is the best option as this only happens in development mode. Put up a pull request and we can continue the conversation there.

@Bashamega
Copy link
Contributor

The issue with getServerSideProps not working locally when using the <Link /> tag but functioning in production is a known issue that has surfaced in various Next.js deployments. This typically happens because when navigating using the <Link /> component, Next.js fetches JSON data through the _next/data endpoint to re-render the page without a full reload. If the data is missing or the fetch fails, the page props might not be populated correctly, leading to issues.

Locally, this could be caused by differences in how environments handle data prefetching and cache control, or it might relate to how Next.js manages client-side navigation. In production, server configurations and CDN setups might handle these differently, which is why it works there but not locally.

@Bashamega
Copy link
Contributor

Glad things work for your environment now.

We want to keep the getServerSideProps, but I'm not sure a window.location.href is the best option as this only happens in development mode. Put up a pull request and we can continue the conversation there.

sure

Bashamega added a commit to Bashamega/app that referenced this issue Oct 10, 2024
…d of link tags

fixed the bug by using a tags instead of link tags

fix open-sauced#4108
Copy link
Contributor

open-sauced bot commented Oct 10, 2024

🎉 This issue has been resolved in version 2.64.0-beta.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Copy link
Contributor

open-sauced bot commented Oct 22, 2024

🎉 This issue has been resolved in version 2.64.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@open-sauced open-sauced bot added the released label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants