Cloudflare Developers

CD

Cloudflare Developers

Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news

Join

Just wondering if anyone is experiencing

Just wondering if anyone is experiencing this and if there is anyway to solve this. I think what ill do for the time being is to also put direct connections to the DB and figure out how to failover during these hours. on the pg side of things: 2024-07-31 10:38:16.201 UTC [569089] [unknown]@[unknown] LOG: invalid length of startup packet 2024-07-31 10:20:26.462 UTC [568369] postgres@db LOG: could not receive data from client: Connection timed out...

Pgjs perf investigation

Hi @AJR, I saw in the Hyperdrive Changelog https://developers.cloudflare.com/hyperdrive/platform/changelog/#2024-05-22 that there were some driver performance improvements for postgres.js. However, I’m testing a hyperdrive connection using a worker and am finding that with caching enabled and { "prepare": true } I get 100% cache misses on a simple SELECT like const [user]: [User?] = await sql`SELECT * FROM users WHERE id = ${userId};. If I set { “prepare”: false } then latency improves,...

There is any list that I can use to

There is any list that I can use to limit hyperdrive connections to my postgres to be only accept cloudflare ips? , I'm running a postgres server but not very confortable to be too open to internet.

I am not sure if this fix should happen

I am not sure if this fix should happen in Cloudflare or Remix but I need to provide a "fake" env var "WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE" for remix vite:build to succeed in CI. I think this should be fixed in Cloudflare (it should detect that it is running in the CI and not fail with the "when running locally" message)...
No description

Aha, got it working, for anyone who runs

Aha, got it working, for anyone who runs into this, in the end it was simpler than I thought, just need compatibility_flags = [ "nodejs_compat" ] in wrangler.toml and then normal functions directory just works™. It took me a while to figure it out because most of the community resources, gh issues etc are slightly outdated and took me a while to understand that node_compat = true is a build time thing not supported by pages and likely won't be (as it is legacy) and compatibility_flags is...

Why does query latency fluctuate so much

Why does query latency fluctuate so much? It's normally around 60 ms but sometimes down to 10 ms for short periods.

I use postgres.js (latest version 3.4.4

I use postgres.js (latest version 3.4.4), hyperdrive and supabase. Every now and then a query fails due to CONNECTION_CLOSED Disabling the hyperdrive cache didn't help and I can't find any open issue on that topic in the postgres.js repo. Am I the only one?

Appointments

@Olivier F @Florent funny you should ask! this is one of our main things in progress currently, we should setup a meeting to talk it through, get some of the details from your side and get your early feedback. These are my availabilities https://calendar.app.google/ynRoYiJudGqyGPRN9

@thomasgauvin I am using AWS lambda

@thomasgauvin I am using AWS lambda behind api gateway with Postgres on neo.tech serverless db.

1. Depends on your use case. There's

1. Depends on your use case. There's overlap in the problems they solve, certainly, but there's also reasons you might want both. 2. Yes, the issue with caching returning empty results was resolved quite a while back...

Hyperdrive Untrusted IP Address Space

Helloo everyone 👋 I facing a puzzling situation. I have a postgres database that I am connecting to via hyperdrive that is run on a server with a firewall which has all of cloudflare's IP's whitelisted. When I trigger the cloudflare worker that uses hyperdrive to do database operations from my home (in Spain) this works. However this worker is a callback handler and whenever the service connects (from Slovakia) the database operations silently fail. I remember working with our sysAdmin to whit...

While waiting for Cloudflare Tunnel

While waiting for Cloudflare Tunnel support for Hyperdrive, are there any resources available about connecting to AWS RDS (via RDS Proxy) directly through a Cloudflare Tunnel from a worker?

What's the recommended way to build a

What's the recommended way to build a site with Pages using Hyperdrive? Every time I build (whether it's locally or on CF), I get this error:
Error: When developing locally, you should use a local Postgres connection string to emulate Hyperdrive functionality. Please setup Postgres locally and set the value of the 'WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE' variable or "HYPERDRIVE"'s "localConnectionString" to the Postgres connection string.
Error: When developing locally, you should use a local Postgres connection string to emulate Hyperdrive functionality. Please setup Postgres locally and set the value of the 'WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE' variable or "HYPERDRIVE"'s "localConnectionString" to the Postgres connection string.
...

Postgres.js with default settings doesn'

Postgres.js with default settings doesn't play very nicely with Hyperdrive at the moment. We're planning a release to roll out in the next couple weeks that will help that significantly. In short, postgres.js uses named prepared statements by default and that can cause several additional round trips depending on your query pattern. For right now if you want to try testing again using node-postgres for best performance that's the best bet. You can also use prepare: false when setting up your connection with postgres.js to help ameliorate some of the performance penalty....

Hi @AutumnCicada! What database are you

Hi @AutumnCicada! What database are you connecting to? It would depend on that. Check out this doc, in the Connection Method, it will indicate how the connection is done. https://developers.cloudflare.com/workers/databases/connecting-to-databases/ There are 2 recommended ways to connect to databases from Workers, depending on your database type: Hyperdrive or API via client library. Traditional SQL databases (like traditional Postgres) should be connected to with Hyperdrive to ensure the connection works well and you don't exhaust your connection limits. ...

Hyperdrive bindings exist in the Pages

Hyperdrive bindings exist in the Pages Projects API under hyperdrive_bindings. You won't be able to use the pg driver, but you can use the Postgres.js driver which only requires the compat flag nodejs_compat (not old node_compat) and it works 🙂

Postgres-js Distributed Performance

Couple of questions: - Why prepare: false - ? (that's going to slow things down!) - Don't define timeouts or lifetimes. - Have you tried the pg driver? We've noticed issues with Postgres.js and working with the maintainer to figure out why...

super sick, would love to hear some

super sick, would love to hear some details

Thread

thanks Jon! is there a way to economically run accelerate just for connection pooling?