Skip to content

Commit

Permalink
V2: Remove support for Node.js v16 (#1225)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Sep 12, 2024
1 parent a054d37 commit cabda22
Show file tree
Hide file tree
Showing 32 changed files with 105 additions and 276 deletions.
25 changes: 1 addition & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Node.js v16 does not provide all necessary fetch types by default, so
# we cannot run tests for @connectrpc/connect-web.
# v16 is tested in a separate job below.
node-version: [22.7.0, 20.17.0, 18.20.4]
node-version: [22.7.0, 20.17.0, 18.20.4, 18.14.1]
name: "test on Node.js ${{ matrix.node-version }}"
steps:
- uses: actions/checkout@v4
Expand All @@ -75,23 +72,3 @@ jobs:
restore-keys: ${{ runner.os }}/test
- run: npm ci
- run: npx turbo run test
test16:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
node-version: [16.20.2]
name: "test on Node.js ${{ matrix.node-version }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "npm"
- uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}/test/${{ github.sha }}
restore-keys: ${{ runner.os }}/test
- run: npm ci
- run: npx turbo run test --filter '!@connectrpc/connect-web'
2 changes: 1 addition & 1 deletion .github/workflows/conformance-express.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [22.7.0, 20.17.0, 18.20.4, 16.20.2]
node-version: [22.7.0, 20.17.0, 18.20.4, 18.14.1]
name: "Node.js ${{ matrix.node-version }}"
timeout-minutes: 10
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conformance-fastify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [22.7.0, 20.17.0, 18.20.4, 16.20.2]
node-version: [22.7.0, 20.17.0, 18.20.4, 18.14.1]
name: "Node.js ${{ matrix.node-version }}"
timeout-minutes: 10
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conformance-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [22.7.0, 20.17.0, 18.20.4, 16.20.2]
node-version: [22.7.0, 20.17.0, 18.20.4, 18.14.1]
side: [client, server]
name: "Node.js ${{ matrix.node-version }} ${{ matrix.side }}"
timeout-minutes: 10
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/conformance-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
# Node.js v16 does not provide all necessary fetch types by default
node-version: [22.7.0, 20.17.0, 18.20.4, 18.16.0]
node-version: [22.7.0, 20.17.0, 18.20.4, 18.14.1]
client: [promise, callback]
name: "Node.js ${{ matrix.node-version }} ${{ matrix.client }}"
timeout-minutes: 10
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ to spin up a service in Node.js, and call it from the web, and from a gRPC clien
in your terminal.

You can serve your Connect RPCs with vanilla Node.js, or use our [server plugins](https://connectrpc.com/docs/node/server-plugins)
for **Fastify**, **Next.js**, and **Express**. We support Node.js v16 and later with
for **Fastify**, **Next.js**, and **Express**. We support Node.js v18.14.1 and later with
the builtin `http` and `http2` modules.

## Other platforms
Expand Down
27 changes: 10 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
},
"type": "module",
"engineStrict": true,
"engines": {
"node": ">=16",
"npm": ">=8"
},
"packageManager": "[email protected]",
"licenseHeader": {
"licenseType": "apache",
Expand Down
9 changes: 4 additions & 5 deletions packages/connect-conformance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
"@bufbuild/protobuf": "^2.0.0",
"@connectrpc/connect": "2.0.0-alpha.1",
"fflate": "^0.8.1",
"tar-stream": "^3.1.7",
"undici": "^5.28.4"
"tar-stream": "^3.1.7"
},
"devDependencies": {
"@bufbuild/protoc-gen-es": "^2.0.0",
"@bufbuild/buf": "^1.39.0",
"@bufbuild/protoc-gen-es": "^2.0.0",
"@types/debug": "^4.1.12",
"@types/node-forge": "^1.3.9",
"@types/tar-stream": "^3.1.3",
"@types/debug": "^4.1.12"
"@types/tar-stream": "^3.1.3"
}
}
1 change: 0 additions & 1 deletion packages/connect-conformance/src/conformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import * as tar from "tar-stream";
import { pipeline } from "node:stream/promises";
import { Readable } from "node:stream";
import { execFileSync } from "node:child_process";
import { fetch } from "undici";
import { scripts } from "../package.json";

export async function run() {
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.14.1"
},
"devDependencies": {
"@connectrpc/connect-conformance": "^2.0.0-alpha.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.14.1"
},
"devDependencies": {
"@connectrpc/connect-conformance": "^2.0.0-alpha.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"lint": "eslint --max-warnings 0 ."
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.14.1"
},
"dependencies": {
"fast-glob": "3.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.14.1"
},
"peerDependencies": {
"@bufbuild/protobuf": "^2.0.0",
Expand Down
10 changes: 4 additions & 6 deletions packages/connect-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"attw": "attw --pack"
},
"type": "module",
"sideEffects": false,
"main": "./dist/cjs/index.js",
"exports": {
".": {
Expand All @@ -29,18 +30,15 @@
}
},
"engines": {
"node": ">=16.0.0"
},
"dependencies": {
"undici": "^5.28.4"
"node": ">=18.14.1"
},
"peerDependencies": {
"@bufbuild/protobuf": "^2.0.0",
"@connectrpc/connect": "2.0.0-alpha.1"
},
"devDependencies": {
"@connectrpc/connect-conformance": "^2.0.0-alpha.1",
"@types/jasmine": "^5.0.0",
"jasmine": "^5.2.0",
"@connectrpc/connect-conformance": "^2.0.0-alpha.1"
"jasmine": "^5.2.0"
}
}
23 changes: 10 additions & 13 deletions packages/connect-node/src/http2-session-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,22 +723,19 @@ function ready(
options.pingIntervalMs = options.pingIntervalMs * 2;
receivedGoAwayEnhanceYourCalmTooManyPings = true;
}
if (errorCode === http2.constants.NGHTTP2_NO_ERROR) {
const nodeMajor = parseInt(process.versions.node.split(".")[0], 10);
// Node.js v16 closes a connection on its own when it receives a GOAWAY
if (errorCode === http2.constants.NGHTTP2_NO_ERROR && streamCount == 0) {
// Node.js v16 closes the connection on its own when it receives a GOAWAY
// frame and there are no open streams (emitting a "close" event and
// destroying the session), but more recent versions do not.
// destroying the session), but later versions do not.
// Calling close() ourselves is ineffective here - it appears that the
// method is already being called, see https://github.com/nodejs/node/blob/198affc63973805ce5102d246f6b7822be57f5fc/lib/internal/http2/core.js#L681
if (streamCount == 0 && nodeMajor >= 18) {
conn.destroy(
new ConnectError(
"received GOAWAY without any open streams",
Code.Canceled,
),
http2.constants.NGHTTP2_NO_ERROR,
);
}
conn.destroy(
new ConnectError(
"received GOAWAY without any open streams",
Code.Canceled,
),
http2.constants.NGHTTP2_NO_ERROR,
);
}
}

Expand Down
3 changes: 0 additions & 3 deletions packages/connect-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Polyfill the Headers API for Node versions < 18
import "./node-headers-polyfill.js";

export { createGrpcWebTransport } from "./grpc-web-transport.js";
export type { GrpcWebTransportOptions } from "./grpc-web-transport.js";
export { createGrpcTransport } from "./grpc-transport.js";
Expand Down
30 changes: 0 additions & 30 deletions packages/connect-node/src/node-headers-polyfill.ts

This file was deleted.

5 changes: 1 addition & 4 deletions packages/connect-node/src/node-universal-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import { createAsyncIterable } from "@connectrpc/connect/protocol";
import { createNodeHttpClient } from "./node-universal-client.js";
import { useNodeServer } from "./use-node-server-helper.spec.js";

// Polyfill the Headers API for Node versions < 18
import "./node-headers-polyfill.js";

describe("node http/2 client closing with RST_STREAM with code CANCEL", function () {
let serverReceivedRstCode: number | undefined;
const server = useNodeServer(() =>
Expand All @@ -41,7 +38,7 @@ describe("node http/2 client closing with RST_STREAM with code CANCEL", function
);
setTimeout(() => {
stream.close(http2.constants.NGHTTP2_CANCEL, () => {
// We are seeing a race condition in Node v16.20.0, where closing
// We are seeing a race condition in Node.js, where closing
// the session right after closing a stream with an RST code
// _sometimes_ sends an INTERNAL_ERROR code.
// Simply delaying the session close until the next tick like
Expand Down
Loading

0 comments on commit cabda22

Please sign in to comment.