Skip to content

Commit 1bc03b9

Browse files
committed
Account for different Node.js version default stream high water mark values.
Also, enable testing Node.js v22 in CI.
1 parent 82c4d62 commit 1bc03b9

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
os: [ubuntu-latest, macos-latest]
10-
node: ["18", "20"]
10+
node: ["18", "20", "22"]
1111
steps:
1212
- uses: actions/checkout@v3
1313
- name: Setup Node.js v${{ matrix.node }}

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636

3737
- Updated the `package.json` field `repository` to conform to new npm requirements.
3838
- Updated GitHub Actions CI config:
39-
- Updated the tested Node.js versions to v18, v20.
39+
- Updated the tested Node.js versions to v18, v20, v22.
4040
- Migrated to the ESLint v9 CLI and “flat” config.
4141
- Integrated a new dev dependency [`eslint-plugin-jsdoc`](https://npm.im/eslint-plugin-jsdoc) and revised types.
4242
- Removed the Node.js CLI option `--unhandled-rejections=throw` in the package script `tests` as it’s now the default for all supported Node.js versions.
43+
- Avoid hardcoding a default value in the type `FileUploadCreateReadStreamOptions` property `highWaterMark` description and use the function `getDefaultHighWaterMark` from `node:stream` in tests.
4344
- Omit unused catch bindings in the function `processRequest`.
4445
- Corrected the JSDoc type `FileUploadCreateReadStreamOptions` in the module `processRequest.mjs`.
4546
- Avoid using `return` in the middleware.

processRequest.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ export default function processRequest(
396396
* `base64url`, or `hex`. Defaults to `utf8`.
397397
* @property {ReadStreamOptions["highWaterMark"]} [highWaterMark] Maximum number
398398
* of bytes to store in the internal buffer before ceasing to read from the
399-
* underlying resource. Defaults to `16384`.
399+
* underlying resource. Defaults to the Node.js default high water mark for
400+
* non object mode streams.
400401
*/
401402

402403
/**

processRequest.test.mjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
throws,
1212
} from "node:assert";
1313
import { createServer } from "node:http";
14+
import { getDefaultHighWaterMark } from "node:stream";
1415
import { text } from "node:stream/consumers";
1516
import { describe, it } from "node:test";
1617

@@ -85,7 +86,10 @@ describe(
8586

8687
ok(stream instanceof ReadStream);
8788
strictEqual(stream.readableEncoding, null);
88-
strictEqual(stream.readableHighWaterMark, 16384);
89+
strictEqual(
90+
stream.readableHighWaterMark,
91+
getDefaultHighWaterMark(false),
92+
);
8993
strictEqual(await text(stream), "a");
9094
} catch (error) {
9195
serverError = error;
@@ -143,7 +147,10 @@ describe(
143147

144148
ok(stream instanceof ReadStream);
145149
strictEqual(stream.readableEncoding, null);
146-
strictEqual(stream.readableHighWaterMark, 16384);
150+
strictEqual(
151+
stream.readableHighWaterMark,
152+
getDefaultHighWaterMark(false),
153+
);
147154
strictEqual(await text(stream), "a");
148155
} catch (error) {
149156
serverError = error;

0 commit comments

Comments
 (0)