Skip to content

Commit

Permalink
add checks for revalidatedTags along with pendingRevalidates
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi12299 committed Sep 29, 2024
1 parent afafe3d commit bb5d3ca
Show file tree
Hide file tree
Showing 41 changed files with 5,217 additions and 0 deletions.
45 changes: 45 additions & 0 deletions next-redirect-revalidate-bug/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
This is a [Next.js](https://nextjs.org/) template to use when reporting a [bug in the Next.js repository](https://github.com/vercel/next.js/issues) with the `app/` directory.

## Getting Started

These are the steps you should follow when creating a bug report:

- Bug reports must be verified against the `next@canary` release. The canary version of Next.js ships daily and includes all features and fixes that have not been released to the stable version yet. Think of canary as a public beta. Some issues may already be fixed in the canary version, so please verify that your issue reproduces before opening a new issue. Issues not verified against `next@canary` will be closed after 30 days.
- Make sure your issue is not a duplicate. Use the [GitHub issue search](https://github.com/vercel/next.js/issues) to see if there is already an open issue that matches yours. If that is the case, upvoting the other issue's first comment is desirable as we often prioritize issues based on the number of votes they receive. Note: Adding a "+1" or "same issue" comment without adding more context about the issue should be avoided. If you only find closed related issues, you can link to them using the issue number and `#`, eg.: `I found this related issue: #3000`.
- If you think the issue is not in Next.js, the best place to ask for help is our [Discord community](https://nextjs.org/discord) or [GitHub discussions](https://github.com/vercel/next.js/discussions). Our community is welcoming and can often answer a project-related question faster than the Next.js core team.
- Make the reproduction as minimal as possible. Try to exclude any code that does not help reproducing the issue. E.g. if you experience problems with Routing, including ESLint configurations or API routes aren't necessary. The less lines of code is to read through, the easier it is for the Next.js team to investigate. It may also help catching bugs in your codebase before publishing an issue.
- Don't forget to create a new repository on GitHub and make it public so that anyone can view it and reproduce it.

## How to use this template

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:

```bash
npx create-next-app --example reproduction-template reproduction-app
```

```bash
yarn create next-app --example reproduction-template reproduction-app
```

```bash
pnpm create next-app --example reproduction-template reproduction-app
```

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [How to Contribute to Open Source (Next.js)](https://www.youtube.com/watch?v=cuoNzXFLitc) - a video tutorial by Lee Robinson
- [Triaging in the Next.js repository](https://github.com/vercel/next.js/blob/canary/contributing.md#triaging) - how we work on issues
- [CodeSandbox](https://codesandbox.io/s/github/vercel/next.js/tree/canary/examples/reproduction-template) - Edit this repository on CodeSandbox

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deployment

If your reproduction needs to be deployed, the easiest way is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Binary file added next-redirect-revalidate-bug/app/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions next-redirect-revalidate-bug/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { cookies } from "next/headers";

export const dynamic = "force-dynamic"

export default function RootLayout({ children }) {
// console.log('render layout', cookies());

return (
<html>
<head />
<body>
<p id="home">{cookies().get("count")?.value || "0"}</p>
{children}
</body>
</html>
);
}
42 changes: 42 additions & 0 deletions next-redirect-revalidate-bug/app/p2/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { revalidatePath } from "next/cache";
import { redirect } from "next/navigation";
import { cookies } from "next/headers";

/** Add your relevant code here for the issue to reproduce */
export default function Home() {
const count = cookies().get("count")?.value || "0";
// console.log('render home', count);

return (
<form>
<button
formAction={async () => {
"use server";
const count = cookies().get("count")?.value || "0";
cookies().set("count", String(Number(count) + 1));
}}
>
Count: {count}
</button>
<button
formAction={async () => {
"use server";
cookies().delete("count");
revalidatePath("/", "layout");
redirect("/");
}}
>
reset
</button>

<button
formAction={async () => {
"use server";
redirect("/");
}}
>
to /
</button>
</form>
);
}
42 changes: 42 additions & 0 deletions next-redirect-revalidate-bug/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { revalidatePath } from "next/cache";
import { redirect } from "next/navigation";
import { cookies } from "next/headers";

/** Add your relevant code here for the issue to reproduce */
export default function Home() {
const count = cookies().get("count")?.value || "0";
// console.log('render home', count);

return (
<form>
<button
formAction={async () => {
"use server";
const count = cookies().get("count")?.value || "0";
cookies().set("count", String(Number(count) + 1));
}}
>
Count: {count}
</button>
<button
formAction={async () => {
"use server";
cookies().delete("count");
revalidatePath("/", "layout");
redirect("/");
}}
>
reset
</button>

<button
formAction={async () => {
"use server";
redirect("/p2");
}}
>
to /p2
</button>
</form>
);
}
5 changes: 5 additions & 0 deletions next-redirect-revalidate-bug/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
8 changes: 8 additions & 0 deletions next-redirect-revalidate-bug/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
reactStrictMode: true,
};

export default nextConfig;
19 changes: 19 additions & 0 deletions next-redirect-revalidate-bug/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "canary",
"react": "19.0.0-rc-5d19e1c8-20240923",
"react-dom": "19.0.0-rc-5d19e1c8-20240923"
},
"devDependencies": {
"@types/node": "20.12.12",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"typescript": "5.3.3"
}
}
Loading

0 comments on commit bb5d3ca

Please sign in to comment.