Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support local postgres, consider pg-cloudflare? #18

Open
ben-xD opened this issue May 26, 2023 · 9 comments
Open

Support local postgres, consider pg-cloudflare? #18

ben-xD opened this issue May 26, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@ben-xD
Copy link

ben-xD commented May 26, 2023

https://www.npmjs.com/package/pg-cloudflare was released 11 days ago. It uses native TCP connections on Cloudflare Workers, since Cloudflare has recently added that capability. https://www.npmjs.com/package/pg

However, this package uses pg, which doesn't take advantage of this.

Adding support for this will mean I can develop offline (in trains, flights) and improves the testability (e.g. just spin a postgres up to run certain tests).

@ben-xD ben-xD changed the title Support local postgres Support local postgres, consider pg-cloudflare? May 26, 2023
@jawj
Copy link
Collaborator

jawj commented May 26, 2023

For now, you can run our WebSocket proxy locally (although this does mean changing some settings on the driver). Gal has blogged about this here: https://gal.hagever.com/posts/running-vercel-postgres-locally

It's on my list to see if we can support Cloudflare TCP in the driver too, though.

@ben-xD
Copy link
Author

ben-xD commented May 26, 2023

Cool, I've got that working, thanks!

@ben-xD ben-xD closed this as completed May 26, 2023
@ben-xD
Copy link
Author

ben-xD commented May 26, 2023

Actually I'll re-open because although things work locally, adding support for Cloudflare connect() might be useful/interesting for Neon users.

@ben-xD ben-xD reopened this May 26, 2023
@jawj
Copy link
Collaborator

jawj commented May 28, 2023

Sure. Of course, you should also be able to just use pg, but the SCRAM auth may burn CPU time.

@TimoWilhelm
Copy link

Is there a way to make the neon function using https fetch available with a local PG instance? I tried the pg proxy mentioned in the post above but I'm guessing this only supports WebSocket Pool right?

@jawj
Copy link
Collaborator

jawj commented Aug 23, 2023

@TimoWilhelm Take a look here for instructions on running our proxy locally: #33 (comment)

We do have plans to make this easier (e.g. with a Docker image or via the Neon CLI) in the future. And sooner than that, we have plans to allow embedding a http/WebSocket port in the query string part of the connection URL, so that no additional code is needed.

@lukahartwig
Copy link

Just ran into this as well. Until you guys find a better solution would it be possible to improve the error message, pointing you to the documentation about the proxy?

@venkatd
Copy link

venkatd commented Nov 14, 2023

I would consider this a very high impact improvement for developer experience. It is causing us a lot of friction that our local and test environments no longer work and that we have to ask all of our engineers to resort to frustrating workarounds.

neondb is ALMOST a drop-in replacement... once localhost just works, adopting neondb will become more of a no-brainer for startups

pg-cloudflare does seem promising so you don't have to force users to install a lot of extra things like Docker

@jawj jawj added the enhancement New feature or request label May 1, 2024
@mmikhan
Copy link

mmikhan commented Oct 14, 2024

For now, you can run our WebSocket proxy locally (although this does mean changing some settings on the driver). Gal has blogged about this here: https://gal.hagever.com/posts/running-vercel-postgres-locally

It's on my list to see if we can support Cloudflare TCP in the driver too, though.

This no longer works in the current version ~0.10* but only does at ~0.9.*~. Even Vercel official Postgres local guide is outdated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants