Just to make sure, Worker -> Hyperdrive connections count towards the 6 open connections limit?
Just to make sure, Worker -> Hyperdrive connections count towards the 6 open connections limit?
mapFound: true on occasion. Logging in pages functions is very limited, but we we were able to reproduce the bug by barraging the API with requests until it falsely returns mapFound: true.maps table doesn't change often - a few modifications a day at best. Seems like a hyperdrive bug to me, but I don't have any evidence to support it except for the info provided above.map.geoguessrId !== params.geoguessrId as a bandaid fix in a desperate attempt to fix it and it seems to be doing the trick. No idea what map object is being returned, logging would really help PostgresError: Internal error from Hyperdrive.
cloudflared running in a docker container and the postgres bitnami contianer running but keep receiving this error when creating my hyperdrive config via Pulumi with v6.1.0:prepare: false and prepare: true and neither seem to make a big difference to the times...--ca-certificate-id and --mtls-certificate-id are specified.node-postgres:With node-postgres, you can install pg-native to boost the speed of both node-postgres and Drizzle by approximately 10%.This won't matter on Workers because Workers doesn't support native extensions.
node-postgres supports providing type parsers on a per-query basis without globally patching things. For more details, see Types Docs.Seems valid but probably somewhat of an advanced use-case?
postgres.js uses prepared statements by default, which you may need to opt out of. This could be a potential issue in AWS environments, among others, so please keep that in mind.Hyperdrive fully supports prepared statements now, and they improve performance so this is probably a benefit of
postgres.js actually// Clean up the connectionAlso, AJR explained why this was a good idea a while back, but might be good to add a line claryfing this in the docs because people might generally assume it's bad practice to close connections on every request.
ctx.waitUntil(sql.end());
max set to 5, so just porting that to the new docs would be good 
postgres://USERNAME:PASSWORD@HOSTNAME_OR_IP_ADDRESS:PORT/database_nameAs many hosted databases have limits on the number of unique connections they can manage, Hyperdrive attempts to keep number of concurrent pooled connections to your origin database lower.


const map = await db.query.maps.findFirst({
where: eq(maps.geoguessrId, params.geoguessrId)
});
if (!map) {
return json({ mapFound: false }, { status: 404 });
}
return json({
mapFound: true
});mapFound: truemapFound: truemapsmap.geoguessrId !== params.geoguessrIdPostgresError: Internal errorfailed to make http request: POST "https://api.cloudflare.com/client/v4/accounts/<redacted>/hyperdrive/configs": 400 Bad Request {
"result": null,
"success": false,
"errors": [
{
"code": 2011,
"message": "Network connection to the provided database was refused. Please check the that host and port are correct and that the database allows connections from public IP addresses
."
}
],
"messages": null
}await sql`select 'hello' as "message";`await sql`select ${'hello'} as "message";`--ca-certificate-id--mtls-certificate-idpostgres://USERNAME:PASSWORD@HOSTNAME_OR_IP_ADDRESS:PORT/database_namename: Deploy App
on:
push:
branches: main
permissions:
contents: read
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install dependencies
run: npm ci
- name: Check DB migrations
run: |
output=$(npx drizzle-kit generate)
echo "$output"
if ! echo "$output" | grep -q "No schema changes, nothing to migrate"; then
echo; echo "Error: Schema changes detected. Please generate migrations before deploying."
exit 1
fi
- name: Apply DB migrations
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: npx drizzle-kit migrate
- name: Deploy application to Cloudflare
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: npx wrangler deploy