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

Remove unstable_revalidate #43119

Merged
merged 2 commits into from Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions packages/next/server/api-utils/node.ts
Expand Up @@ -509,13 +509,6 @@ export async function apiResolver(
}
) => revalidate(urlPath, opts || {}, req, apiContext)

// TODO: remove in next minor (current v12.2)
apiRes.unstable_revalidate = () => {
throw new Error(
`"unstable_revalidate" has been renamed to "revalidate" see more info here: https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#on-demand-revalidation`
)
}

const resolver = interopDefault(resolverModule)
let wasPiped = false

Expand Down
5 changes: 0 additions & 5 deletions packages/next/shared/lib/utils.ts
Expand Up @@ -269,11 +269,6 @@ export type NextApiResponse<T = any> = ServerResponse & {
*/
clearPreviewData: (options?: { path?: string }) => NextApiResponse<T>

/**
* @deprecated `unstable_revalidate` has been renamed to `revalidate`
*/
unstable_revalidate: () => void

revalidate: (
urlPath: string,
opts?: {
Expand Down
14 changes: 0 additions & 14 deletions test/e2e/prerender.test.ts
Expand Up @@ -752,20 +752,6 @@ describe('Prerender', () => {
expect(value).toMatch(/Hi \[third\] \[fourth\]/)
})

if (!(global as any).isNextDeploy) {
it('should show error about renaming unstable_revalidate', async () => {
const res = await fetchViaHTTP(next.url, '/api/manual-revalidate', {
pathname: '/blog/first',
deprecated: '1',
})
expect(res.status).toBe(500)

expect(next.cliOutput).toContain(
'"unstable_revalidate" has been renamed to "revalidate"'
)
})
}

if ((global as any).isNextStart) {
// TODO: dev currently renders this page as blocking, meaning it shows the
// server error instead of continuously retrying. Do we want to change this?
Expand Down
3 changes: 0 additions & 3 deletions test/e2e/prerender/pages/api/manual-revalidate.js
@@ -1,7 +1,4 @@
export default async function handler(req, res) {
if (req.query.deprecated) {
await res.unstable_revalidate(req.query.pathname)
}
// WARNING: don't use user input in production
// make sure to use trusted value for revalidating
let revalidated = false
Expand Down