Unverified Commit 9fce9964 authored by Max Proske's avatar Max Proske Committed by GitHub

Remove `unstable_revalidate` (#43119)

Reverts https://github.com/vercel/next.js/pull/38070

I stumbled upon @ijjk's TODO to remove the deprecated
`unstable_revalidate` renaming error and e2e test after v12.2.

```tsx
// TODO: remove in next minor (current v12.2)
```

I also removed the deprecated function stub, since it probably shouldn't
exist if there's no error, e2e test, and doesn't match the new
`revalidate` function signature anyways.

<img width="675" alt="image"
src="https://user-images.githubusercontent.com/14317828/202842660-be9977e2-252c-4ccf-84fc-e0c00bf25e05.png">
parent ecfd2f4c
...@@ -509,13 +509,6 @@ export async function apiResolver( ...@@ -509,13 +509,6 @@ export async function apiResolver(
} }
) => revalidate(urlPath, opts || {}, req, apiContext) ) => 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) const resolver = interopDefault(resolverModule)
let wasPiped = false let wasPiped = false
......
...@@ -269,11 +269,6 @@ export type NextApiResponse<T = any> = ServerResponse & { ...@@ -269,11 +269,6 @@ export type NextApiResponse<T = any> = ServerResponse & {
*/ */
clearPreviewData: (options?: { path?: string }) => NextApiResponse<T> clearPreviewData: (options?: { path?: string }) => NextApiResponse<T>
/**
* @deprecated `unstable_revalidate` has been renamed to `revalidate`
*/
unstable_revalidate: () => void
revalidate: ( revalidate: (
urlPath: string, urlPath: string,
opts?: { opts?: {
......
...@@ -752,20 +752,6 @@ describe('Prerender', () => { ...@@ -752,20 +752,6 @@ describe('Prerender', () => {
expect(value).toMatch(/Hi \[third\] \[fourth\]/) 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) { if ((global as any).isNextStart) {
// TODO: dev currently renders this page as blocking, meaning it shows the // TODO: dev currently renders this page as blocking, meaning it shows the
// server error instead of continuously retrying. Do we want to change this? // server error instead of continuously retrying. Do we want to change this?
......
export default async function handler(req, res) { 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 // WARNING: don't use user input in production
// make sure to use trusted value for revalidating // make sure to use trusted value for revalidating
let revalidated = false let revalidated = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment