postgres icon indicating copy to clipboard operation
postgres copied to clipboard

support neon's sql-over-websocket protocol

Open nicksrandall opened this issue 1 year ago • 4 comments

Neon is a popular postgres provider that is an open source alternative to AWS Aurora. In order to support connecting to their database in more runtimes (like cloudflare workers), they have implemented a "sql-over-websocket" protocol that these runtimes can use to connect to their database with less "cold-start" latency than other approaches (like hyperdrive).

If you're open to landing this change in this repo, that would be awesome! That said, I understand that this use-case might be niche enough that you may not want to sign up for the ongoing maintenance. If that is the case, I will likely just publish a fork to our own npm namespace to support this use-case.

Notes

  • Most of this is just directly copied from the "cf" module. I'll do my best to highlight the things that were actually changed.

Potential future work

  • Neon also supports sql-over-http which has the lowest startup latency but there is some limitations (like it doesn't support interactive transactions). It would be really nice to bake in some logic that this library could use the http protocol for simple one-shot queries and use the ws protocol for everything else?

nicksrandall avatar Oct 03 '24 16:10 nicksrandall

Any chance to get this PR approved ? It would be a great addition and help to use postgres.js with neon, Thanks for the effort so far :)

sahinvardar avatar Feb 15 '25 17:02 sahinvardar

FWIW, we are using this in production. You can get it here:

https://github.com/brevitybuilder/postgres

nicksrandall avatar Feb 15 '25 23:02 nicksrandall

Thanks for the heads-up! I assume you meant this repo? The link you shared returns a 404—perhaps it's private?

🔗 https://github.com/brevitybuilder/postgres-fork

It would be great if the repo's author could review this PR so we can work towards including it in the next release. Let us know if there's anything we can do to help make that happen!

sahinvardar avatar Feb 16 '25 11:02 sahinvardar

+1 This would be great.

fsommers avatar Feb 18 '25 06:02 fsommers