N
Neon14mo ago
like-gold

Using Transactions in a Script

I'm trying to run a transaction in a file using tsx (e.g., tsx index.ts), but I'm getting the following error: "Error: All attempts to open a WebSocket to connect to the database failed." Is it possible to run transactions in this setup? When I remove the transactions and switch to using Neon HTTP, everything works, but I'd prefer to keep the transactions in place.
3 Replies
passive-yellow
passive-yellow14mo ago
i have some services made with typescript and running with tsx (i use only in develoment) without problems what module are you using?
like-gold
like-goldOP14mo ago
Hey thanks. I found the issue. I needed to be using the Pool from 'pg' instead of the neon serverelss pacakge
fair-rose
fair-rose14mo ago
Curious that websockets didn't work for you whereas pg did. I've not seen that before. However if pg works for you, that's what I would recommend anyway

Did you find this page helpful?