Skip to content

Commit 00ed66b

Browse files
authored
fix: autosave potentially losing latest: true w/ race condition (#8894)
Fixes a potential race condition where versions could lose `latest: true` and potentially also introduce a conflict with the `parent` field. We now explicitly define these as we update versions in the `saveVersion` function.
1 parent 44e52b0 commit 00ed66b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/payload/src/versions/saveVersion.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export const saveVersion = async ({
8282

8383
const data: Record<string, unknown> = {
8484
createdAt: new Date(latestVersion.createdAt).toISOString(),
85+
latest: true,
86+
parent: id,
8587
updatedAt: now,
8688
version: {
8789
...versionData,

0 commit comments

Comments
 (0)