Files
Jiachi LiuandGitHub d714bb32aa feat: support isr reason for on request error (#68845)
### What

Provide `revalidateReason` in the `errorContext` argument of
`onRequestError` API

#### API

```ts
revalidateReason?: 'on-demand' | 'stale' | undefined
```

### Why

With this property, developer is able to determine if current error is
attached to an ISR request.

* `stale` means it revalidated due to the cache is expired
* `on-demand` means it revalidated due to a user initiated revalidation,
e.g. using `res.revalidate` to revalidate certain path

### Misc

* We don't generate edge entry of instrumentation when there's no edge
routes but instrumentation is presented

Note: for PPR case we'll tackle it later with another PPR specific task,
since we need to provide the render is a postpone render or just normal
render

Closes NDX-23
2024-08-14 21:44:51 +02:00

12 lines
269 B
JavaScript

export default async function handler(req, res) {
const { path } = req.query
try {
await res.revalidate(path)
return res.json({ revalidated: true })
} catch (err) {
console.error('Failed to revalidate:', err)
}
res.json({ revalidated: false })
}