Fixed revalidateTag
writing to tags-manifest.json
concurrently
#52823
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 inrevalidateTag
withfs.createWriteStream
due torevalidateTag
being called withawait Promise.all(staticGenerationStore.pendingRevalidates)
(it is not safe to write to a file in a parallel manner, as mentioned infs.writeFile
's documentation).Fixes #49509 (likely)
We can also change it so that
createWriteStream
returns aWritableStream
instead of aWriteStream
usingWritable.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 usecreateWriteStream
just fine with an Edge Route Handler and a Node.js page though, because the one that actually callsrevalidateTag
isapp-render.tsx
.