From 897c0d092f2557e1d740771c2cbfca590e603fd9 Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Fri, 11 Oct 2024 14:55:48 +0100 Subject: [PATCH 1/7] Adding a new partial for compatibility_flags and compatibility_date. --- .../hyperdrive/configuration/connect-to-postgres.mdx | 12 +++--------- .../index.mdx | 4 ++-- .../partials/workers/nodejs-compat-wrangler-toml.mdx | 12 ++++++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 src/content/partials/workers/nodejs-compat-wrangler-toml.mdx diff --git a/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx b/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx index 5ab6648897361b0..d82fdfad0b14371 100644 --- a/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx +++ b/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx @@ -30,7 +30,6 @@ The command above will output the ID of your Hyperdrive, which you will need to ```toml # required for database drivers to function -compatibility_flags = [ "nodejs_compat_v2" ] [[hyperdrive]] binding = "HYPERDRIVE" @@ -48,7 +47,7 @@ Hyperdrive uses Workers [TCP socket support](/workers/runtime-apis/tcp-sockets/# | Driver | Documentation | Minimum Version Required | Notes | | ----------------------------- | ---------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Postgres.js (**recommended**) | [https://github.com/porsager/postgres](https://github.com/porsager/postgres) | `postgres@3.4.4` | Supported in both Workers & Pages. | -| 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. | +| 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`](/workers/runtime-apis/nodejs/) `compatibility_flags` and the `compatibility_date` to be set. Requires wrangler `3.78.7` or later. | | Drizzle | [https://orm.drizzle.team/](https://orm.drizzle.team/) | `0.26.2`^ | | | Kysely | [https://kysely.dev/](https://kysely.dev/) | `0.26.3`^ | | | [rust-postgres](https://github.com/sfackler/rust-postgres) | [https://docs.rs/postgres/latest/postgres/](https://docs.rs/postgres/latest/postgres/) | `v0.19.8` | Use the [`query_typed`](https://docs.rs/postgres/latest/postgres/struct.Client.html#method.query_typed) method for best performance. | @@ -97,14 +96,9 @@ Install the `node-postgres` driver: npm install pg ``` -**Ensure you have `compatibility_flags = ["nodejs_compat_v2"]` set in your `wrangler.toml` configuration file**: +**Ensure you have `compatibility_flags` and `compatibility_date` set in your `wrangler.toml` configuration file** as shown below: -```toml -# other fields elided -# -# Required for node-postgres to work -compatibility_flags = ["nodejs_compat_v2"] -``` + Create a new `Client` instance and pass the Hyperdrive parameters: diff --git a/src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx b/src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx index 1a10e806fd3acc3..e24db30c9a962a4 100644 --- a/src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx +++ b/src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx @@ -145,8 +145,8 @@ This command outputs your Hyperdrive ID. You can now bind your Hyperdrive config ```toml name = "timescale-api" main = "src/index.ts" -compatibility_date = "2024-08-21" -compatibility_flags = [ "nodejs_compat_v2"] +compatibility_date = "DATE" +compatibility_flags = [ "nodejs_compat"] [[hyperdrive]] binding = "HYPERDRIVE" diff --git a/src/content/partials/workers/nodejs-compat-wrangler-toml.mdx b/src/content/partials/workers/nodejs-compat-wrangler-toml.mdx new file mode 100644 index 000000000000000..acf781cf90de59a --- /dev/null +++ b/src/content/partials/workers/nodejs-compat-wrangler-toml.mdx @@ -0,0 +1,12 @@ +--- +{} + +--- + +```toml title="wrangler.toml" +# other fields elided +# +# Required for node-postgres to work +compatibility_flags = [ "nodejs_compat" ] +compatibility_date = "2024-09-23" +``` From de132a3bc1c74768e198927cda13beabda55781d Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Fri, 11 Oct 2024 15:04:18 +0100 Subject: [PATCH 2/7] Using partial file in the relevant location. --- src/content/docs/workers/runtime-apis/nodejs/index.mdx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/content/docs/workers/runtime-apis/nodejs/index.mdx b/src/content/docs/workers/runtime-apis/nodejs/index.mdx index 9ea2ad704ba538e..5e0ced26e540467 100644 --- a/src/content/docs/workers/runtime-apis/nodejs/index.mdx +++ b/src/content/docs/workers/runtime-apis/nodejs/index.mdx @@ -20,10 +20,7 @@ You can view which APIs are supported using the [Node.js compatability matrix](h To enable both built-in runtime APIs and polyfills for your Worker or Pages project, add the [`nodejs_compat`](/workers/configuration/compatibility-dates/#nodejs-compatibility-flag) [compatibility flag](/workers/configuration/compatibility-dates/#nodejs-compatibility-flag) to your `wrangler.toml`, and set your compatibility date to September 23rd, 2024 or later. -```toml title="wrangler.toml" -compatibility_flags = [ "nodejs_compat" ] -compatibility_date = "2024-09-23" -``` + :::note As of September 23rd, 2024, the `nodejs_compat` compatibility flag enables the exact same behavior as the `nodejs_compat_v2` compatibility flag, as long as your compatibility date is set to September 23rd, 2024 or later. From adde1a60231be68a5fc01756cf362876bdc891be Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Fri, 11 Oct 2024 15:05:25 +0100 Subject: [PATCH 3/7] Revert "Using partial file in the relevant location." This reverts commit de132a3bc1c74768e198927cda13beabda55781d. --- src/content/docs/workers/runtime-apis/nodejs/index.mdx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/content/docs/workers/runtime-apis/nodejs/index.mdx b/src/content/docs/workers/runtime-apis/nodejs/index.mdx index 5e0ced26e540467..9ea2ad704ba538e 100644 --- a/src/content/docs/workers/runtime-apis/nodejs/index.mdx +++ b/src/content/docs/workers/runtime-apis/nodejs/index.mdx @@ -20,7 +20,10 @@ You can view which APIs are supported using the [Node.js compatability matrix](h To enable both built-in runtime APIs and polyfills for your Worker or Pages project, add the [`nodejs_compat`](/workers/configuration/compatibility-dates/#nodejs-compatibility-flag) [compatibility flag](/workers/configuration/compatibility-dates/#nodejs-compatibility-flag) to your `wrangler.toml`, and set your compatibility date to September 23rd, 2024 or later. - +```toml title="wrangler.toml" +compatibility_flags = [ "nodejs_compat" ] +compatibility_date = "2024-09-23" +``` :::note As of September 23rd, 2024, the `nodejs_compat` compatibility flag enables the exact same behavior as the `nodejs_compat_v2` compatibility flag, as long as your compatibility date is set to September 23rd, 2024 or later. From 1275c4bc72cbfc81c7f73a788e21d6ac56aa3c06 Mon Sep 17 00:00:00 2001 From: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:08:31 +0100 Subject: [PATCH 4/7] Update src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx --- .../serverless-timeseries-api-with-timescale/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx b/src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx index e24db30c9a962a4..e69dddd50bce80a 100644 --- a/src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx +++ b/src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx @@ -145,7 +145,7 @@ This command outputs your Hyperdrive ID. You can now bind your Hyperdrive config ```toml name = "timescale-api" main = "src/index.ts" -compatibility_date = "DATE" +compatibility_date = "2024-09-23" compatibility_flags = [ "nodejs_compat"] [[hyperdrive]] From 40eaa7aa3b43cd756190fe43ad98646ba2772f20 Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Fri, 11 Oct 2024 15:23:19 +0100 Subject: [PATCH 5/7] Updating the compatibility reference in the table. --- .../docs/hyperdrive/configuration/connect-to-postgres.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx b/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx index d82fdfad0b14371..d97c9a013e4c730 100644 --- a/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx +++ b/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx @@ -47,7 +47,7 @@ Hyperdrive uses Workers [TCP socket support](/workers/runtime-apis/tcp-sockets/# | Driver | Documentation | Minimum Version Required | Notes | | ----------------------------- | ---------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Postgres.js (**recommended**) | [https://github.com/porsager/postgres](https://github.com/porsager/postgres) | `postgres@3.4.4` | Supported in both Workers & Pages. | -| 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`](/workers/runtime-apis/nodejs/) `compatibility_flags` and the `compatibility_date` to be set. Requires wrangler `3.78.7` or later. | +| 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 `compatibility_flags = ["nodejs_compat"]` and `compatibility_date = "2024-09-23"` - refer to [Node.js compatibility](/workers/runtime-apis/nodejs). Requires wrangler `3.78.7` or later. | | Drizzle | [https://orm.drizzle.team/](https://orm.drizzle.team/) | `0.26.2`^ | | | Kysely | [https://kysely.dev/](https://kysely.dev/) | `0.26.3`^ | | | [rust-postgres](https://github.com/sfackler/rust-postgres) | [https://docs.rs/postgres/latest/postgres/](https://docs.rs/postgres/latest/postgres/) | `v0.19.8` | Use the [`query_typed`](https://docs.rs/postgres/latest/postgres/struct.Client.html#method.query_typed) method for best performance. | From 22f564ec02e970ebf93e9e26164da8f44a3ec865 Mon Sep 17 00:00:00 2001 From: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:57:58 +0100 Subject: [PATCH 6/7] Update src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx --- .../docs/hyperdrive/configuration/connect-to-postgres.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx b/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx index d97c9a013e4c730..02efee7baafe119 100644 --- a/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx +++ b/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx @@ -31,6 +31,9 @@ The command above will output the ID of your Hyperdrive, which you will need to ```toml # required for database drivers to function +compatibility_flags = ["nodejs_compat"] +compatibility_date = "2024-09-23" + [[hyperdrive]] binding = "HYPERDRIVE" id = "" From 31329a8c17ee96aa0e94f4fd0f282a376f9c7e8b Mon Sep 17 00:00:00 2001 From: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:58:20 +0100 Subject: [PATCH 7/7] Update src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx --- .../docs/hyperdrive/configuration/connect-to-postgres.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx b/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx index 02efee7baafe119..b1e3ebb4b2491d1 100644 --- a/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx +++ b/src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx @@ -30,7 +30,6 @@ The command above will output the ID of your Hyperdrive, which you will need to ```toml # required for database drivers to function - compatibility_flags = ["nodejs_compat"] compatibility_date = "2024-09-23"