Skip to content

Commit

Permalink
Account for different Node.js version default stream high water mark …
Browse files Browse the repository at this point in the history
…values.

Also, enable testing Node.js v22 in CI.
  • Loading branch information
jaydenseric committed Oct 7, 2024
1 parent 82c4d62 commit 1bc03b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node: ["18", "20"]
node: ["18", "20", "22"]
steps:
- uses: actions/checkout@v3
- name: Setup Node.js v${{ matrix.node }}
Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@

- Updated the `package.json` field `repository` to conform to new npm requirements.
- Updated GitHub Actions CI config:
- Updated the tested Node.js versions to v18, v20.
- Updated the tested Node.js versions to v18, v20, v22.
- Migrated to the ESLint v9 CLI and “flat” config.
- Integrated a new dev dependency [`eslint-plugin-jsdoc`](https://npm.im/eslint-plugin-jsdoc) and revised types.
- 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.
- Avoid hardcoding a default value in the type `FileUploadCreateReadStreamOptions` property `highWaterMark` description and use the function `getDefaultHighWaterMark` from `node:stream` in tests.
- Omit unused catch bindings in the function `processRequest`.
- Corrected the JSDoc type `FileUploadCreateReadStreamOptions` in the module `processRequest.mjs`.
- Avoid using `return` in the middleware.
Expand Down
3 changes: 2 additions & 1 deletion processRequest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ export default function processRequest(
* `base64url`, or `hex`. Defaults to `utf8`.
* @property {ReadStreamOptions["highWaterMark"]} [highWaterMark] Maximum number
* of bytes to store in the internal buffer before ceasing to read from the
* underlying resource. Defaults to `16384`.
* underlying resource. Defaults to the Node.js default high water mark for
* non object mode streams.
*/

/**
Expand Down
11 changes: 9 additions & 2 deletions processRequest.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
throws,
} from "node:assert";
import { createServer } from "node:http";
import { getDefaultHighWaterMark } from "node:stream";
import { text } from "node:stream/consumers";
import { describe, it } from "node:test";

Expand Down Expand Up @@ -85,7 +86,10 @@ describe(

ok(stream instanceof ReadStream);
strictEqual(stream.readableEncoding, null);
strictEqual(stream.readableHighWaterMark, 16384);
strictEqual(
stream.readableHighWaterMark,
getDefaultHighWaterMark(false),
);
strictEqual(await text(stream), "a");
} catch (error) {
serverError = error;
Expand Down Expand Up @@ -143,7 +147,10 @@ describe(

ok(stream instanceof ReadStream);
strictEqual(stream.readableEncoding, null);
strictEqual(stream.readableHighWaterMark, 16384);
strictEqual(
stream.readableHighWaterMark,
getDefaultHighWaterMark(false),
);
strictEqual(await text(stream), "a");
} catch (error) {
serverError = error;
Expand Down

0 comments on commit 1bc03b9

Please sign in to comment.