vercel / storage

Vercel Postgres, KV, Blob, and Edge Config
https://vercel.com/storage
Apache License 2.0
502 stars 56 forks source link

Kysely transactions #162

Closed roelandxyz closed 1 year ago

roelandxyz commented 1 year ago

I found out the hard way that transactions are not yet supported in Kysely/Vercel Is this on the roadmap? Maybe add something in the readme that transactions are not yet supported?

  beginTransaction(): Promise<void> {
    throw new VercelPostgresKyselyError(
      'kysely_transactions_not_supported',
      'Transactions are not supported yet.',
    );
  }
emirotin commented 1 year ago

Yeah, this was much unexpected, after I've invested some time into tailoring my code to run with Vercel serverless functions and Vercel PG

vvo commented 1 year ago

Hey @roelandmoors and @emirotin have you tried to use the original transaction example from Kysely as seen here: https://kysely.dev/docs/examples/transactions/simple-transaction? Let me know how it goes

emirotin commented 1 year ago

@vvo nope, instantly switched to another PG provider, transactions are crucial for my use-case

roelandxyz commented 1 year ago

Sorry, I don't remember. I'm using a different stack now. But how could it work if it is not implemented? (kysely_transactions_not_supported)

vvo commented 1 year ago

Sorry, I don't remember. I'm using a different stack now.

Well I am just wondering if this was the right method (beginTransaction) to use versus the current kysely documentation which says to use .transaction. i.e. it might just works nowadays.

Closing, let's wait for someone else to come about this.

emirotin commented 1 year ago

@vvo pretty sure I was following the Kysely docs, I believe beginTransaction is being called by the transaction method

jswent commented 10 months ago

Is there still nothing done on this? This library is essentially useless to me if transactions are not supported.

@emirotin what provider did you switch to for Vercel PG?

emirotin commented 10 months ago

It was claimed that it should work https://x.com/cramforce/status/1713185661996707987?s=20, yet my followup Q was unanswered.

I switched to fly.io, works nicely so far.

On Thu, Nov 30, 2023, 19:11 James Swent @.***> wrote:

Is there still nothing done on this? This library is essentially useless to me if transactions are not supported.

@emirotin https://github.com/emirotin what provider did you switch to for Vercel PG?

— Reply to this email directly, view it on GitHub https://github.com/vercel/storage/issues/162#issuecomment-1834188633, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEAMCGA5XAOOORUAZEOSKDYHC44RAVCNFSM6AAAAAAYIRWCZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZUGE4DQNRTGM . You are receiving this because you were mentioned.Message ID: @.***>

wskidmore commented 6 months ago

Adding another voice to the "vercel storage is a non-starter" as transactions are a necessity. It is such an unwelcome surprise after moving everything to vercel then blam, not supported, go find a different db provider.

The messages above about beginTransaction vs transaction doesnt really track as transaction calls beginTransaction AND vercel throws the same error that transactions are not supported when attempting either.

Vercel states that its because Neon doesnt support transactions.. but they do. And the un-official but still sorta official kysely adapter has them fully implemented: https://github.com/seveibar/kysely-neon/blob/main/src/neon-dialect.ts#L75

jlvdh commented 1 month ago

At this point this still doesn't seem to be implemented. I feel this should be mentioned in the docs with Vercel as it is indeed a crucial function.

In the end I implemented @neondatabase/serverless instead of the vercel one, which seems to support transactions.

https://github.com/neondatabase/neon-vercel-kysely