pg example not working

I followed the example from the Cloudflare documentation for connecting to Postgres using node-postgres / pq at the link: https://developers.cloudflare.com/hyperdrive/configuration/connect-to-postgres/#node-postgres–pg. However, I encountered the error “this.stream.once is not a function.” According to this compatibility matrix (https://workers-nodejs-compat-matrix.pages.dev/), nodejs_compat_v2 should support the .once method on streams. Is there a related issue or a step I might have overlooked? My code is based on the documentation, and you can view it here: https://github.com/waigel/example-pg-cloudflare. Any suggestions or help would be appreciated!
Cloudflare Docs
Connect to PostgreSQL | Hyperdrive
Hyperdrive supports PostgreSQL and PostgreSQL-compatible databases, popular drivers and Object Relational Mapper (ORM) libraries that use those drivers.
1 Reply
meakr
meakr2w ago
Hey @mike, I'll dig in here in a bit. If you set node_compat = true in your wrangler.toml instead of compatability_flags = ["nodejs_compat_v2"] do you know if it works? It should work with V2 and node_compat = true is meant to be replaced, but it'd be helpful for debugging to see if it works in this case.
Want results from more Discord servers?
Add your server