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

Fixed revalidateTag writing to tags-manifest.json concurrently #52823

Closed
wants to merge 8 commits into from

Conversation

DuCanhGH
Copy link
Contributor

@DuCanhGH DuCanhGH commented Jul 18, 2023

What?

Relands #51887, now that it has gone stale.

This PR fixes revalidateTag, revalidatePath not working properly when called multiple times.

How?

It fixes these functions by replacing the await fs.writeFile call in revalidateTag with fs.createWriteStream due to revalidateTag being called with await Promise.all(staticGenerationStore.pendingRevalidates) (it is not safe to write to a file in a parallel manner, as mentioned in fs.writeFile's documentation).

Fixes #49509 (likely)

We can also change it so that createWriteStream returns a WritableStream instead of a WriteStream using Writable.toWeb, but it is experimental, was just added in Node.js 17 but we still support Node 16.8 and it's not like pages using the Edge runtime support static anyway. Seems that we can use createWriteStream just fine with an Edge Route Handler and a Node.js page though, because the one that actually calls revalidateTag is app-render.tsx.

@ijjk
Copy link
Member

ijjk commented Jul 18, 2023

Allow CI Workflow Run

  • approve CI run for commit: 9e27502

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@DuCanhGH DuCanhGH changed the title fix(revalidating): fixed revalidateTag writing to one file in a parallel manner Fixed revalidateTag writing to one file in a parallel manner Jul 18, 2023
@DuCanhGH DuCanhGH changed the title Fixed revalidateTag writing to one file in a parallel manner Fixed revalidateTag writing to fetch-cache/tags-manifest.json concurrently Jul 18, 2023
@DuCanhGH DuCanhGH changed the title Fixed revalidateTag writing to fetch-cache/tags-manifest.json concurrently Fixed revalidateTag writing to tags-manifest.json concurrently Jul 18, 2023
@DuCanhGH DuCanhGH requested a review from ztanner as a code owner July 24, 2023 18:52
@DuCanhGH DuCanhGH closed this Aug 6, 2023
@DuCanhGH DuCanhGH deleted the ducanhgh-fix-revalidate-tag branch August 14, 2023 09:00
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[NEXT-1199] only the last call to revalidateTag works in DEV mode
2 participants