Skip to content

Commit

Permalink
fix: db transaction errors caused by checkDocumentLockStatus (#11287)
Browse files Browse the repository at this point in the history
Just like #11269, we stop passing through `req` to db operations in `checkDocumentLockStatus`.

After extensive testing, this seems to get rid of all transaction errors that occurred when I was testing autosave against a remote mongo DB.

We keep the `req` for postgres, as it mysteriously breaks in CI - this cannot be reproduced locally
  • Loading branch information
AlessioGr authored Feb 21, 2025
1 parent 0594701 commit 9728d80
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/payload/src/utilities/checkDocumentLockStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const checkDocumentLockStatus = async ({
collection: 'payload-locked-documents',
limit: 1,
pagination: false,
req,
sort: '-updatedAt',
where: lockedDocumentQuery,
})
Expand Down Expand Up @@ -93,7 +92,8 @@ export const checkDocumentLockStatus = async ({
// Perform the delete operation regardless of overrideLock status
await payload.db.deleteMany({
collection: 'payload-locked-documents',
req, //
// Not passing req fails on postgres
req: payload.db.name === 'mongoose' ? undefined : req,
where: lockedDocumentQuery,
})
}

0 comments on commit 9728d80

Please sign in to comment.