Skip to content

Commit 11fce3a

Browse files
ijjkkodiakhq[bot]Timer
authored
Remove unstable_ prefix from unstable_notFound (#18283)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Joe Haddad <[email protected]>
1 parent 7cb68f7 commit 11fce3a

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

packages/next/next-server/server/render.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ export async function renderToHTML(
625625
key !== 'revalidate' &&
626626
key !== 'props' &&
627627
key !== 'redirect' &&
628-
key !== 'unstable_notFound'
628+
key !== 'notFound'
629629
)
630630

631631
if (invalidKeys.includes('unstable_revalidate')) {
@@ -636,10 +636,10 @@ export async function renderToHTML(
636636
throw new Error(invalidKeysMsg('getStaticProps', invalidKeys))
637637
}
638638

639-
if ('unstable_notFound' in data && data.unstable_notFound) {
639+
if ('notFound' in data && data.notFound) {
640640
if (pathname === '/404') {
641641
throw new Error(
642-
`The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!`
642+
`The /404 page can not return notFound in "getStaticProps", please remove it to continue!`
643643
)
644644
}
645645

@@ -759,10 +759,14 @@ export async function renderToHTML(
759759
}
760760

761761
const invalidKeys = Object.keys(data).filter(
762-
(key) =>
763-
key !== 'props' && key !== 'redirect' && key !== 'unstable_notFound'
762+
(key) => key !== 'props' && key !== 'redirect' && key !== 'notFound'
764763
)
765764

765+
if ((data as any).unstable_notFound) {
766+
throw new Error(
767+
`unstable_notFound has been renamed to notFound, please update the field to continue. Page: ${pathname}`
768+
)
769+
}
766770
if ((data as any).unstable_redirect) {
767771
throw new Error(
768772
`unstable_redirect has been renamed to redirect, please update the field to continue. Page: ${pathname}`
@@ -773,10 +777,10 @@ export async function renderToHTML(
773777
throw new Error(invalidKeysMsg('getServerSideProps', invalidKeys))
774778
}
775779

776-
if ('unstable_notFound' in data) {
780+
if ('notFound' in data) {
777781
if (pathname === '/404') {
778782
throw new Error(
779-
`The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!`
783+
`The /404 page can not return notFound in "getStaticProps", please remove it to continue!`
780784
)
781785
}
782786

packages/next/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export type GetStaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery> = {
8888
export type GetStaticPropsResult<P> =
8989
| { props: P; revalidate?: number | boolean }
9090
| { redirect: Redirect; revalidate?: number | boolean }
91-
| { unstable_notFound: true }
91+
| { notFound: true }
9292

9393
export type GetStaticProps<
9494
P extends { [key: string]: any } = { [key: string]: any },
@@ -133,7 +133,7 @@ export type GetServerSidePropsContext<
133133
export type GetServerSidePropsResult<P> =
134134
| { props: P }
135135
| { redirect: Redirect }
136-
| { unstable_notFound: true }
136+
| { notFound: true }
137137

138138
export type GetServerSideProps<
139139
P extends { [key: string]: any } = { [key: string]: any },

test/integration/getserversideprops/pages/not-found/[slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function Page(props) {
2222
export const getServerSideProps = ({ query }) => {
2323
if (query.hiding) {
2424
return {
25-
unstable_notFound: true,
25+
notFound: true,
2626
}
2727
}
2828

test/integration/getserversideprops/pages/not-found/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function Page(props) {
2222
export const getServerSideProps = ({ query }) => {
2323
if (query.hiding) {
2424
return {
25-
unstable_notFound: true,
25+
notFound: true,
2626
}
2727
}
2828

test/integration/i18n-support/pages/not-found/fallback/[slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function Page(props) {
2626
export const getStaticProps = ({ params, locale, locales }) => {
2727
if (locale === 'en' || locale === 'nl') {
2828
return {
29-
unstable_notFound: true,
29+
notFound: true,
3030
}
3131
}
3232

test/integration/i18n-support/pages/not-found/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function Page(props) {
2424
export const getStaticProps = ({ locale, locales }) => {
2525
if (locale === 'en' || locale === 'nl') {
2626
return {
27-
unstable_notFound: true,
27+
notFound: true,
2828
}
2929
}
3030

0 commit comments

Comments
 (0)