Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
updateTag updates unrelated tags | GoodFirstPicks

updateTag updates unrelated tags

vercel/next.js 3 comments 11d ago
View on GitHub
highopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

Cache tag invalidation behavior is inconsistent and affects unrelated tags.

AI Summary

The issue involves inconsistent behavior of `updateTag`, which sometimes updates unrelated cache tags along with the specified one. This requires understanding the cache mechanism and potentially modifying how tags are invalidated. The scope is unclear due to unpredictable behavior and potential cross-cutting changes.

Issue Description

Link to the code that reproduces this issue

https://github.com/prananta/next-use-cache-private-bug

To Reproduce

  1. npm run build
  2. npm run start
  3. open localhost:3000
  4. click one of the Refresh buttons

Current vs. Expected behavior

According to the doc in https://nextjs.org/docs/app/api-reference/functions/updateTag, updateTag is supposed to update cached data for a specific cache tag. But in my repo, updating certain tag updates other cached data with different tags too. In the repo example, i have three functions that use use cache, use cache: remote and use cache: private respectively. They also have different tags.

export const timeInAsia = async () => {
  "use cache: remote";
  cacheTag("time-in-asia");
  cacheLife("hours");
  console.log(`Fetching Asia time`);
  await new Promise((resolve) => setTimeout(resolve, 1000));
  const now = getDateInTimezone("Asia/Tokyo");

  return now;
};

export const timeInUTC = async () => {
  "use cache";
  cacheTag("time-in-utc");
  cacheLife("hours");
  console.log(`Fetching UTC time`);

  await new Promise((resolve) => setTimeout(resolve, 1000));
  const now = getDateInTimezone("UTC");

  return now;
};

export const timeInAmerica = async () => {
  "use cache: private";
  cacheTag("time-in-america");
  cacheLife("hours");
  console.log(`Fetching America time`);

  await new Promise((resolve) => setTimeout(resolve, 1000));

  const cookieStore = await cookies();
  console.log(cookieStore.getAll());

  const now = getDateInTimezone("America/New_York");

  return now;
};

When I called updateTag('time-in-utc') from a server action for example, not only timeInUtc is re-executed, but also timeInAmerica. The updateTag's behavior is unpredictable right now. Sometimes it only updates the cached data for given tag, sometimes it affects other tags too. This happens in both dev and production.

Provide environment information

Operating System:
  Platform: darwin
  Arch:

GitHub Labels

Cache Components

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 30 points when you complete it!

Risk Flags

  • cache behavior unpredictability
  • cross-cutting changes
Loading labels...

Details

Points30 pts
Difficultyhigh
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno