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

fix: now if loading user profile fails an error is thrown instead of 404ing #4043

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pages/u/[username]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { jsonLdScriptProps } from "react-schemaorg";
import { Person } from "schema-dts";

import { useRouter } from "next/router";
import { captureException } from "@sentry/nextjs";
import SEO from "layouts/SEO/SEO";

import useContributorPullRequests from "lib/hooks/api/useContributorPullRequests";
Expand Down Expand Up @@ -118,7 +119,15 @@ export const getServerSideProps = async (context: UserSSRPropsContext) => {
});

if (!req.ok) {
return { notFound: true };
if (req.status === 404) {
nickytonline marked this conversation as resolved.
Show resolved Hide resolved
return {
notFound: true,
};
}

const errorText = `Failed to load user profile: ${username}`;
captureException(new Error(errorText, { cause: req.statusText }));
throw new Error(errorText);
}

const userData = (await req.json()) as DbUser;
Expand Down
Loading