Skip to content

Commit 47e46d2

Browse files
authored
hyperdrive: nodejs_compat_v2 (cloudflare#16995)
* hyperdrive: nodejs_compat_v2 * clarify wrangler version * hyperdrive: node compat changelog * fix indentation * fix????
1 parent ca6ec15 commit 47e46d2

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/content/changelogs/hyperdrive.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ productLink: "/hyperdrive/"
55
productArea: Developer platform
66
productAreaLink: /workers/platform/changelog/platform/
77
entries:
8+
- publish_date: "2024-09-20"
9+
title: The `node-postgres` (pg) driver is now supported for Pages applications using Hyperdrive.
10+
description: |-
11+
The popular `pg` ([node-postgres](https://github.com/brianc/node-postgres) driver no longer requires the legacy `node_compat` mode, and can now be used in both Workers and Pages for connecting to Hyperdrive. This uses the new (improved) Node.js compatibility in Workers and Pages.
12+
13+
You can set [`compatibility_flags = ["nodejs_compat_v2"]`](/workers/runtime-apis/nodejs/) in your `wrangler.toml` or via the Pages dashboard to benefit from this change. Visit the [Hyperdrive documentation on supported drivers](/hyperdrive/configuration/connect-to-postgres/#supported-drivers) to learn more about the driver versions supported by Hyperdrive.
814
- publish_date: "2024-08-19"
915
title: Improved caching for Postgres.js
1016
description: |-

src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Hyperdrive uses Workers [TCP socket support](/workers/runtime-apis/tcp-sockets/#
4848
| Driver | Documentation | Minimum Version Required | Notes |
4949
| ----------------------------- | ---------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
5050
| Postgres.js (**recommended**) | [https://github.com/porsager/postgres](https://github.com/porsager/postgres) | `[email protected]` | Supported in both Workers & Pages. |
51-
| node-postgres - `pg` | [https://node-postgres.com/](https://node-postgres.com/) | `pg@8.11.0` | `8.11.4` introduced a bug with URL parsing and will not work. `8.11.5` fixes this. Requires the [`node_compat`](/workers/wrangler/configuration/#add-polyfills-using-wrangler) compatibility flag to be set. |
51+
| node-postgres - `pg` | [https://node-postgres.com/](https://node-postgres.com/) | `pg@8.13.0` | `8.11.4` introduced a bug with URL parsing and will not work. `8.11.5` fixes this. Requires the [`nodejs_compat_v2`](/workers/runtime-apis/nodejs/) compatibility flag to be set. Requires wrangler `3.78.7` or later. |
5252
| Drizzle | [https://orm.drizzle.team/](https://orm.drizzle.team/) | `0.26.2`^ | |
5353
| Kysely | [https://kysely.dev/](https://kysely.dev/) | `0.26.3`^ | |
5454

@@ -96,12 +96,13 @@ Install the `node-postgres` driver:
9696
npm install pg
9797
```
9898

99-
Ensure you have `node_compat = true` set in your `wrangler.toml` configuration file:
99+
**Ensure you have `compatibility_flags = ["nodejs_compat_v2"]` set in your `wrangler.toml` configuration file**:
100100

101101
```toml
102102
# other fields elided
103-
# required for node-postgres to work
104-
node_compat = true
103+
#
104+
# Required for node-postgres to work
105+
compatibility_flags = ["nodejs_compat_v2"]
105106
```
106107

107108
Create a new `Client` instance and pass the Hyperdrive parameters:

0 commit comments

Comments
 (0)