#99337·Next.js

On-demand ISR revalidation can report success while retaining pre-publish content

Author: iamibiCreated Sep 27, 2026Updated Sep 27, 2026
LabelsRuntimePages Router

Link to the code that reproduces this issue

https://github.com/iamibi/next.js/tree/repro/on-demand-revalidate

To Reproduce

The public Pages Router reproduction has a delayed ISR render, a simulated CMS publish endpoint, and an endpoint that calls res.revalidate('/'). The ISR page reads a simulated CMS version before a three-second render. Publishing increments the version; the API endpoint then calls res.revalidate('/'):

typescript
// pages/index.tsx (key lines from getStaticProps)
export const getStaticProps: GetStaticProps<Props> = async () => {
  const version = readVersion()
  const readAt = Date.now()
  await new Promise((resolve) => setTimeout(resolve, RENDER_DELAY_MS))
  const renderedAt = Date.now()
  logRender({ version, readAt, renderedAt })
  return { props: { version, readAt, renderedAt }, revalidate: 5 }
}

// pages/api/revalidate.ts (key lines from handler)
export default async function handler(_req: NextApiRequest, res: NextApiResponse) {
  await res.revalidate('/')
  return res.json({ revalidated: true })
}

Run the included timing script, which builds the app, starts next start, and checks that the background render was still in flight when the revalidation was requested:

bash
git clone --branch repro/on-demand-revalidate --single-branch https://github.com/iamibi/next.js.git
cd next.js
npm install
npx next info
npm run repro

The script loads /, waits ten seconds for its five-second ISR interval to expire, and requests / again. That second request returns STALE and starts a render that reads version 1. After 0.75 seconds, the script publishes version 2 via POST /api/publish, calls POST /api/revalidate, waits one second, and reads / again. A timing miss is reported as INCONCLUSIVE (exit 2), so it is distinct from a reproduced bug (exit 1).

The request sequence can also be run manually after rm -rf .data && npm run build && npm start in another terminal:

bash
curl -s -o /dev/null -D - http://localhost:3000/ | grep -i x-nextjs-cache
sleep 10
curl -s -o /dev/null -D - http://localhost:3000/ | grep -i x-nextjs-cache  # STALE; starts regeneration
sleep 0.75
curl -s -X POST http://localhost:3000/api/publish; echo
curl -s -X POST http://localhost:3000/api/revalidate; echo
sleep 1
curl -s http://localhost:3000/ | grep -o 'id="version">[0-9]*'

Selected output from a recorded [email protected] run; ... marks text omitted from long lines:

[repro +10.03s]    status=200 x-nextjs-cache=STALE version=1 ...
[repro +10.80s]    status=200 published version 2
[next  +13.03s] [getStaticProps] read version 1, finished after 2999ms
[repro +13.06s]    status=200 body={"revalidated":true} took 2253ms
[repro +14.07s]    status=200 x-nextjs-cache=HIT version=1 ...
[repro +14.07s]    getStaticProps runs that read version 2 before res.revalidate() returned: 0
[repro +14.07s] RESULT: BUG REPRODUCED, res.revalidate('/') reported success, but / serves version 1 ...

Selected lines from a fresh [email protected] run on 2026-09-27 show the same failure (page timing details omitted):

[repro +10.02s]    status=200 x-nextjs-cache=STALE version=1
[repro +10.78s]    status=200 published version 2
[repro +13.03s]    status=200 body={"revalidated":true} took 2246ms
[repro +14.03s]    status=200 x-nextjs-cache=HIT version=1
[repro +14.03s]    getStaticProps runs that read version 2 before res.revalidate() returned: 0
[repro +14.03s] RESULT: BUG REPRODUCED, res.revalidate('/') reported success, but / serves version 1

For comparison, the recorded run on the earlier unaffected 15.5.10 produced a second getStaticProps render that read version 2 and served it after revalidation:

[next  +13.79s] [getStaticProps] read version 2, finished after 3001ms
[repro +13.80s]    status=200 body={"revalidated":true} took 3017ms
[repro +14.81s]    getStaticProps runs that read version 2 before res.revalidate() returned: 1
[repro +14.81s] RESULT: EXPECTED BEHAVIOR, / serves version 2

### Current vs. Expected behavior

On published `[email protected]`, the script reproduced the bug in five of five runs, and a fresh run on canary.50 reproduced it again: the API reported successful revalidation, but the next request still served version N. Stable `16.3.6` reproduced it in three of three runs. The on-demand request joined the earlier background render rather than starting a render that read the newly published value; that older result was stored with a fresh cache timestamp.

An on-demand revalidation requested after the publish should run a new render for that path and make version N+1 available after it succeeds. The earlier render may finish for callers already waiting on it, but it should not
overwrite the newer result. A local build of the fix returned version N+1 in three of three runs; it was not a published package.

### Provide environment information

```bash
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.6.0: Tue Aug 18 17:51:33 PDT 2026; root:xnu-12377.161.15.700.19~2/RELEASE_ARM64_T8132
  Available memory (MB): 24576
  Available CPU cores: 10
Binaries:
  Node: 24.19.0
  npm: N/A
  Yarn: N/A
  pnpm: 11.19.0
Relevant Packages:
  next: 16.4.0-canary.50
  eslint-config-next: N/A
  react: 19.3.0
  react-dom: 19.3.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Pages Router, Runtime

Which stage(s) are affected? (Select all that apply)

next start (local), Other (Deployed)

Additional context

ResponseCache separates normal and on-demand requests in its get batcher, but its later revalidateBatcher uses only the route key. An on-demand request can therefore reuse an in-flight normal render that read data before publication. The regression follows #80853. A proposed fix in the linked pull request lets an on-demand request supersede a normal render and prevents the older result from being persisted. That protection orders writes only within one process; it does not coordinate multiple instances that share a cache handler. This issue was reproduced through Pages res.revalidate(), not App Router tag or path revalidation.