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

router.push() does not get the latest ISR on-demand revalidated page #40927

Closed
1 task done
anasqadrei opened this issue Sep 27, 2022 · 4 comments · Fixed by #40932
Closed
1 task done

router.push() does not get the latest ISR on-demand revalidated page #40927

anasqadrei opened this issue Sep 27, 2022 · 4 comments · Fixed by #40932
Labels
bug Issue was opened via the bug report template.

Comments

@anasqadrei
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101
Binaries:
      Node: 14.19.1
      npm: 8.6.0
      Yarn: N/A
      pnpm: N/A
Relevant packages:
      next: 12.3.2-canary.9
      eslint-config-next: 12.3.1
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

Safari version 16.0 (17614.1.25.9.10, 17614)

How are you deploying your application? (if relevant)

next start or Vercel

Describe the Bug

After ISR on-demand revalidation and waiting to the page to be regenerated, router.push() doesn't show the regenerated page where next/link does. It happens when you push or link from the page to itself.

Expected Behavior

After revalidation, router.push() should show the new content.

Link to reproduction

https://codesandbox.io/s/ancient-dew-d28bz0

To Reproduce

The CodeSandbox above uses next dev. I'm referring to next start or deployment on Vercel.

  1. Go to: https://csb-d28bz0-nz1ywkx5j-anasqadrei.vercel.app
    index.js page has getStaticProps that will return the time of generation and show it on the page
export async function getStaticProps() {
  return {
    props: {
      time: new Date().getTime(),
    },
  }
}
  1. The page has Link, push, push with skipClientCache, replace and reload. If you click any of those, the time won't change. You'll get the previously generated page.
  2. Click revalidate. This will call the revalidate api. getStaticProps will be called, it will return a new time and a new page will be generated
  3. Wait few seconds for the page to be regenerated
  4. Click push, push with skipClientCache or replace. Nothing will happen. The time won't change. It gets the old generated page.
  5. Click Link. The time will change and you will see the newly regenerated page.

The expected behaviour is to see a new time whenever push is clicked after revalidate

@anasqadrei anasqadrei added the bug Issue was opened via the bug report template. label Sep 27, 2022
@ijjk
Copy link
Member

ijjk commented Sep 27, 2022

Closing as a duplicate of #39186 (comment)

@ijjk ijjk closed this as completed Sep 27, 2022
@anasqadrei
Copy link
Author

@ijjk I read #39186 before writing this. My code is different. There is no racing condition in my code.

@ijjk
Copy link
Member

ijjk commented Sep 27, 2022

Ah I see, the reproduction fails to return a response in the revalidate API route so it timed out and never revalidated properly so seemed like a duplicate. After fixing the reproduction I am able to see the issue the described.

@ijjk ijjk reopened this Sep 27, 2022
ijjk added a commit that referenced this issue Sep 27, 2022
Fixes: #40927

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants