payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
28.81k stars 1.79k forks source link

Cannot delete any collection object with Azure CosmosDB: Transaction is not active #6820

Open shazz opened 5 months ago

shazz commented 5 months ago

Link to reproduction

No response

Describe the Bug

I configured payloadcms to connect to my Azure Cosmos DB for MongoDB account. It works well except when I try to delete any kind of Collection object. It fails and I can see in pino logs:

{"level":50,"time":1718663749924,"pid":226951,"hostname":"****","name":"payload","msg":
"MongoServerError: Error=2, Details='Response status code does not indicate success: BadRequest (400); 
Substatus: 1101; ActivityId: 3c364136-6d79-4dc0-89d8-e4d67641ca62; 
Reason: (Response status code does not indicate success: 
BadRequest (400); Substatus: 1101; 
ActivityId: 3c364136-6d79-4dc0-89d8-e4d67641ca62; Reason: (Response status code does not indicate success: 
BadRequest (400); 
Substatus: 1101; 
ActivityId: 3c364136-6d79-4dc0-89d8-e4d67641ca62; 
Reason: (Message: {\"Errors\":[\"Transaction is not active\"]}
ActivityId: 3c364136-6d79-4dc0-89d8-e4d67641ca62, 
Request URI: /apps/3e76277b-491a-43ea-877f-4c9e1cbbbd9f/services/f77f5fb7-8df6-4fdd-996c-5eb222ad13a4/partitions/6ed5b480-e957-466a-a862-659e89c243e3/replicas/133631013038295515p/, 
RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.20348 cosmos-netstandard-sdk/3.18.0);););
    at /***/node_modules/mongodb/src/operations/delete.ts:135:44
    at /***/node_modules/mongodb/src/cmap/connection_pool.ts:569:13
    at /***/node_modules/mongodb/src/sdam/server.ts:367:13
    at handleOperationResult (/***/node_modules/mongodb/src/sdam/server.ts:500:14)
    at Connection.onMessage (/***/node_modules/mongodb/src/cmap/connection.ts:461:5)
    at MessageStream.<anonymous> (***/node_modules/mongodb/src/cmap/connection.ts:241:56)
    at MessageStream.emit (node:events:519:28)
    at MessageStream.emit (node:domain:488:12)
    at processIncomingData (/***/node_modules/mongodb/src/cmap/message_stream.ts:188:12)
    at MessageStream._write (/***/node_modules/mongodb/src/cmap/message_stream.ts:69:5)"}

To Reproduce

  1. Create any collection with delete enabled:
    
    import type { CollectionConfig } from 'payload/types'

const Categories: CollectionConfig = { access: { delete: () => true, update: () => true, read: () => true, }, admin: { useAsTitle: 'title', }, fields: [ { name: 'title', type: 'text', required: true, }, ], slug: 'categories', }

export default Categories



2. With the admin webpage, create a category
3. With the admin webpage, delete a category
4. Nothing happens visually
5. check the logs

### Payload Version

create-payload-app@latest / @payloadcms/db-mongodb@^1.0.0

### Adapters and Plugins

db-mongodb

Any idea how to fix this issue?
shazz commented 5 months ago

update: to avoid it, I set:

  db: mongooseAdapter({
    url: process.env.DATABASE_URI,
    transactionOptions: false
  }),

but...

DanRibbens commented 2 months ago

Is there error still occuring? I don't know that I can reproduce it.