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

Not working with Mongo transactions #190

Closed
carstenblt opened this issue Aug 18, 2024 · 1 comment
Closed

Not working with Mongo transactions #190

carstenblt opened this issue Aug 18, 2024 · 1 comment

Comments

@carstenblt
Copy link

OK, this took me a while.

In payload.config.ts I needed to set

db: mongooseAdapter({
  url: process.env.DATABASE_URI,
  transactionOptions: false // <-- this
})

to get it working. Otherwise

  • creating a new document fails in the findOrCreateArticleDirectory method of filesApiByDocument called by the afterChange hook because the document does not yet exist in the DB, when executing
this.payload.update({
  collection: this.collectionSlug,
  id: this.document.id,
  data: {
    crowdinArticleDirectory,
 },
});
  • updating an existing document fails with MongoServerError: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction. Didn't debug this yet
@thompsonsj
Copy link
Owner

Have been using Payload CMS version 3 with MongoDB transactions since the fixes in #200 and #225 and have not experienced the error since. Can safely assume it is resolved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants