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

[NEXT-1199] only the last call to revalidateTag works in DEV mode #49509

Closed
1 task done
Torsten85 opened this issue May 9, 2023 · 3 comments
Closed
1 task done

[NEXT-1199] only the last call to revalidateTag works in DEV mode #49509

Torsten85 opened this issue May 9, 2023 · 3 comments
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked Pages Router Related to Pages Router.

Comments

@Torsten85
Copy link

Torsten85 commented May 9, 2023

Verify canary release

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

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000
    Binaries:
      Node: 19.6.0
      npm: 9.4.0
      Yarn: N/A
      pnpm: 8.4.0
    Relevant packages:
      next: 13.4.2-canary.3
      eslint-config-next: 13.4.1
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.4

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true), Data fetching (gS(S)P, getInitialProps)

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/divine-lake-8pfqub

To Reproduce

  • Load the homepage at "/".
  • See two fetched timestamps
  • Goto "/flush"
  • Go back to "/"
  • Only the last timestamp gets refetched

Describe the Bug

the two requests have to separate tags "a", and "b".
"/flush" will revalidate both tags
only the last call to revalidateTag works
This only happens in DEV mode, in production it works as expected.
If you introduce a delay between calls, it works even in DEV mode.

Expected Behavior

multiple calls to revalidateTag should work in DEV mode

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1199

@Torsten85 Torsten85 added the bug Issue was opened via the bug report template. label May 9, 2023
@github-actions github-actions bot added area: app App directory (appDir: true) Pages Router Related to Pages Router. labels May 9, 2023
@timneutkens timneutkens added the linear: next Confirmed issue that is tracked by the Next.js team. label May 17, 2023
@timneutkens timneutkens changed the title only the last call to revalidateTag works in DEV mode [NEXT-1199] only the last call to revalidateTag works in DEV mode May 17, 2023
@martin-coded
Copy link

I have the same issue, that only the last tag is getting revalidated. As workaround I tested to loop over all the tags and make for every single one a new request. This works as expected.

Is it correct, that I could set the same tag for different queries and with the revalidateTag() method, all queries with the same tags are getting revalidated?

// /api/revalidate

export async function POST(req: NextRequest) {
  const data = await req.json();
  for (tag of data.tags) {
    await fetch(`https://dev.app.ch:3001/api/revalidate?tag=${tag}`);
  }

  return NextResponse.json({revalidated: true, now: Date.now()});
}

export async function GET(req: NextRequest) {
  const tag = req.nextUrl.searchParams.get('tag');
  revalidateTag(tag);
  return NextResponse.json({revalidated: true, now: Date.now()});
}

@ztanner
Copy link
Member

ztanner commented Jul 26, 2023

Hey @Torsten85! I wanted to check and see if you're still seeing this behavior on the latest version of Next.js? Looks like this might have been fixed recently

@ztanner ztanner closed this as completed Nov 29, 2023
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. 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 Dec 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked Pages Router Related to Pages Router.
Projects
None yet
4 participants