Skip to content

Commit 1696682

Browse files
authored
ci: restore EMFILE test on Node.js 26 (#21297)
1 parent 2c7f5d6 commit 1696682

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ jobs:
9191
- name: Fuzz Test
9292
run: node Makefile fuzz
9393
- name: Test EMFILE Handling
94-
# Node.js 26.8+ no longer reliably triggers `EMFILE` for small-file reads.
95-
# See: https://github.com/nodejs/node/pull/65327
96-
# TODO: Re-enable after replacing this with deterministic error injection.
97-
if: matrix.node != '26.x'
9894
run: npm run test:emfile
9995

10096
test_on_browser:

‎tools/check-emfile-handling.js‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//------------------------------------------------------------------------------
1111

1212
const fs = require("node:fs");
13-
const { readFile } = require("node:fs/promises");
13+
const { writeFile } = require("node:fs/promises");
1414
const { execSync } = require("node:child_process");
1515
const os = require("node:os");
1616

@@ -76,15 +76,22 @@ function generateFiles() {
7676
}
7777

7878
/**
79-
* Generates an EMFILE error by reading all files in the output directory.
79+
* Generates an EMFILE error by writing to all files in the output directory.
80+
* Since Node.js 26.8.0, `readFile()` runs open, fstat, read, and close in a
81+
* single thread pool task, so concurrent reads no longer accumulate file
82+
* descriptors and cannot trigger EMFILE (https://github.com/nodejs/node/pull/65327).
83+
* Concurrent writes still can, and writing is also what `--fix` does above.
8084
* @returns {undefined}
8185
*/
8286
async function generateEmFileError() {
8387
const results = await Promise.allSettled(
8488
Array.from({ length: FILE_COUNT }, (_, i) => {
8589
const fileName = `file_${i}.js`;
8690

87-
return readFile(`${OUTPUT_DIRECTORY}/${fileName}`);
91+
return writeFile(
92+
`${OUTPUT_DIRECTORY}/${fileName}`,
93+
"// Overwritten",
94+
);
8895
}),
8996
);
9097
const failedResult = results.find(({ status }) => status === "rejected");

0 commit comments

Comments
 (0)