payloadcms / payload-3.0-demo

The official demo for Payload 3.0
https://next-payload-3-0-test.vercel.app
433 stars 140 forks source link

Postgres transaction error [Beta 26] #196

Closed zelenovsky closed 4 months ago

zelenovsky commented 4 months ago

Some times postgres connection gets dropped with this error without any trace: Error: cannot begin transaction: Cannot read properties of undefined (reading 'transaction')

It didn't happen on beta 22

Do you have any ideas?

jmikrut commented 4 months ago

Hey @zelenovsky we have been seeing sporadic reports of this going back all the way to Alpha. We have a theory about why this happens, but we can’t reproduce it ourselves consistently. Any chance you can help us reproduce? Did you have a certain set of steps that makes this happen consistently with your project?

Are you using getPayload anywhere in your code? Try to swap it out for getPayloadHMR instead, if so.

zelenovsky commented 4 months ago

@jmikrut I noticed that it started to happen when I add a custom Switcher component here:

admin: {
    user: Users.slug,
    components: {
      actions: [Switcher]
    }
  },

and inside this component I use getPayload fn. When I remove this component I don't receive this error

UPD: It seems that I don't need to call getPayload to trigger the error. I just need a custom component to make this error happen

jmikrut commented 4 months ago

hey @zelenovsky I think we have gotten to the bottom of this one. A new beta will come out today, and after which, will you let us know if you see this happen again? or re-open another issue?