Commit 990aefdf566 for nodejs

commit 990aefdf5662b2181ce47c5009b301c2bfbceae6
Author: James M Snell <jasnell@gmail.com>
Date:   Fri Sep 18 18:40:27 2026 +0000

    lib: fix stream loading bug in node:bench

    Not all of the stream APIs are correctly loaded until
    the `node:stream` module is loaded.

    Signed-off-by: James M Snell <jasnell@gmail.com>
    Assisted-by: Opencode
    PR-URL: https://github.com/nodejs/node/pull/66114
    Fixes: https://github.com/nodejs/node/issues/41641
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

diff --git a/lib/internal/bench_runner/benchmarks_stream.js b/lib/internal/bench_runner/benchmarks_stream.js
index 295aa20483c..3e3a86dd157 100644
--- a/lib/internal/bench_runner/benchmarks_stream.js
+++ b/lib/internal/bench_runner/benchmarks_stream.js
@@ -24,7 +24,7 @@ const {
   SetPrototypeValues,
   Symbol,
 } = primordials;
-const Readable = require('internal/streams/readable');
+const { Readable } = require('stream');
 const { deserializeError, serializeError } = require('internal/error_serdes');
 const {
   codes: {
diff --git a/test/parallel/test-bench-stream.js b/test/parallel/test-bench-stream.js
index 8fe0870ae55..dbb68f8be97 100644
--- a/test/parallel/test-bench-stream.js
+++ b/test/parallel/test-bench-stream.js
@@ -2,6 +2,7 @@
 'use strict';

 const common = require('../common');
+const { spawnSyncAndAssert } = require('../common/child_process');
 const assert = require('assert');
 const { createRunner } = require('node:bench');
 const { setImmediate } = require('timers/promises');
@@ -375,6 +376,32 @@ async function testRecordOwnership() {
   assert.strictEqual(streamSummary.counts.total, 7);
 }

+function testOperatorsWithoutStreamModule() {
+  // Readable operators such as map() and toArray() are attached when
+  // node:stream is loaded. node:assert and ../common load node:stream, so
+  // check the operators in a child process that loads only node:bench.
+  const script = `
+    const { createRunner } = require('node:bench');
+    const runner = createRunner({ yieldBetweenSamples: false });
+    runner.bench('operators', { samples: 1 }, (b) => {
+      b.record({ operations: 1, duration_ns: 1n });
+    });
+    runner.run()
+      .map((record) => record.type)
+      .toArray()
+      .then((types) => console.log(types.includes('bench:complete')));
+  `;
+  spawnSyncAndAssert(process.execPath, [
+    '--experimental-bench',
+    '--no-warnings',
+    '-e',
+    script,
+  ], {
+    stdout: 'true',
+    trim: true,
+  });
+}
+
 (async () => {
   await testReadableBackpressure();
   await testPlanBackpressure();
@@ -385,4 +412,5 @@ async function testRecordOwnership() {
   await testReportingFailureSettlesBenchmarks();
   await testSummaryListenerFailure();
   await testRecordOwnership();
+  testOperatorsWithoutStreamModule();
 })().then(common.mustCall());