Neon errors
I cannot for the life of me create a hyperdrive connection to my Neon PG DB. It is always stuck in "inactive" and returns an error when attempting to use it "SERVER_ERROR: NeonDbError: Server error (HTTP status 530): error code: 1016"
Is there some black magic I need to perform on the Neon side of things (because the hyperdrive side seems super simple)
9 Replies
Inactive just means it hasn't had any traffic in the last 24 hours.
If it creates successfully that means it can connect, so it's not a permissions or connectivity issue.
Can you paste some code snippets of how you're trying to use it in your Worker?
Thanks for that.
It's boilerplate stuff; the binding ("HYPERDRIVE", the ID, a localConnectionString) and then
c.env.HYPERDRIVE.connectionString
Ah, I think I see the issue. We don't support Neon's driver. You'll need to swap it out for something like postgres.js or node-postgres
Without going too far into the weeds, Neon's driver does a looot of custom stuff with the wire protocol.
Aaaaaah. Thanks. I think I copy-pasta'd that from somewhere along the way, which is interesting.
Drizzle ORM - Neon
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Is there a recommended option between postgres.js or node-postgres for CF?
postgres.js is a bit slower but will be way friendlier for using on Workers and Pages due to being cleaner about how they use their node APIs and their imports. Generally that's what we recommend.
The snippet from here will give you the ideal connection settings for it, with Hyperdrive.
https://developers.cloudflare.com/hyperdrive/get-started/
Cloudflare Docs
Getting started · Hyperdrive docs
Hyperdrive accelerates access to your existing databases from Cloudflare Workers, making even single-region databases feel globally distributed.
Great, easy fix!