MogoServerError: transaction aborted

default discord avatar
adampilks
last month
6

Am on the latest version of payload and the mongo adapter, and when doing anything related to the admin, or when querying data from the api, I get 100s of these errors in the logs:



[13:43:46] ERROR (payload): MongoServerError: Transaction with { txnNumber: 1 } has been aborted.

at Connection.onMessage (/home/node/app/node_modules/mongodb/src/cmap/connection.ts:449:20)

at MessageStream.<anonymous> (/home/node/app/node_modules/mongodb/src/cmap/connection.ts:241:56)

at MessageStream.emit (node:events:513:28)

at processIncomingData (/home/node/app/node_modules/mongodb/src/cmap/message_stream.ts:188:12)

at MessageStream._write (/home/node/app/node_modules/mongodb/src/cmap/message_stream.ts:69:5)

at writeOrBuffer (node:internal/streams/writable:392:12)

at _write (node:internal/streams/writable:333:10)

at MessageStream.Writable.write (node:internal/streams/writable:337:10)

at TLSSocket.ondata (node:internal/streams/readable:766:22)

at TLSSocket.emit (node:events:513:28)


Anyone run into this before or know what might be causing it.



Thanks

  • discord user avatar
    dribbens
    Payload Team
    last month

    I'm not sure this is enough to diagnose your issue unfortunately. You might have async hooks competing and erroring as a result

  • default discord avatar
    adampilks
    4 weeks ago

    Thanks for the heads up, I found something in the transactions docs that I think I might have implemented incorrectly. Was worried it was some setup issue, but seems its a hooks implementation as you suggest

  • discord user avatar
    dribbens
    Payload Team
    4 weeks ago

    Cool, hope you figure out. If you see anything we should add to the docs let us know!

  • default discord avatar
    brianjm
    yesterday

    What did you figure out here? I switched from a local MongoDB instance to Atlas, and have been working through lots of these errors and others. At first glance, it appears to be a race condition.



    MongoServerError: Transaction with { txnNumber: 8 } has been aborted

    MongoRuntimeError: Attempted illegal state transition from [TRANSACTION_ABORTED] to [TRANSACTION_ABORTED]
  • default discord avatar
    adampilks
    yesterday

    If I remember rightly. I had a hook that was also updating the database but was not returning the req properly to tie it together into a single transaction. In my case the hook was no longer needed so I just removed it. The page on transactions in the docs helped me a lot. I missed this when I first made the hook

  • default discord avatar
    brianjm
    yesterday

    Thanks. I believe this issue may be the cause.

    https://github.com/payloadcms/payload/issues/4350
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.