Commit 291d62f8854 for nodejs

commit 291d62f8854751fefdd84935f6e8623472145991
Author: Matteo Collina <hello@matteocollina.com>
Date:   Sat Nov 14 08:55:28 2026 +0100

    stream: drop rejection step for sync transforms

    transformStreamDefaultControllerPerformTransform chained a rejection
    step onto the result of every transform() call. A non-thenable result
    cannot reject, so return the shared resolved promise directly and save
    a promise allocation and a microtask per chunk.

    The write promise of a transform whose transform() returns a
    non-thenable now settles one microtask earlier than in the reference
    implementation. The relative order of all stream events is unchanged.

    Signed-off-by: Matteo Collina <hello@matteocollina.com>
    PR-URL: https://github.com/nodejs/node/pull/67339
    Reviewed-By: Paolo Insogna <paolo@cowtech.it>
    Reviewed-By: James M Snell <jasnell@gmail.com>

diff --git a/lib/internal/webstreams/transformstream.js b/lib/internal/webstreams/transformstream.js
index ba6d51f813f..60c7bd65bb9 100644
--- a/lib/internal/webstreams/transformstream.js
+++ b/lib/internal/webstreams/transformstream.js
@@ -597,11 +597,11 @@ function transformStreamDefaultControllerError(controller, error) {

 // Mirrors the reference implementation's
 // `promiseCall(transformAlgorithm, ...).then(undefined, rejectionSteps)`:
-// the returned promise settles one microtask after the (coerced) result
-// does, and a rejection errors the transform stream before propagating.
-// The raw transform callback plus the shared resolved promise for
-// non-thenable results replace the previous async wrapper's two implicit
-// promises per chunk.
+// a rejection errors the transform stream before propagating. A
+// non-thenable result cannot reject, so it maps to the shared resolved
+// promise without the rejection step; the write then completes one
+// microtask earlier than in the reference implementation, with the
+// relative order of all stream events unchanged.
 function transformStreamDefaultControllerPerformTransform(controller, chunk) {
   const controllerState = controller[kState];
   const transformAlgorithm = controllerState.transformAlgorithm;
@@ -617,10 +617,9 @@ function transformStreamDefaultControllerPerformTransform(controller, chunk) {
   }
   if (result === null ||
       (typeof result !== 'object' && typeof result !== 'function')) {
-    result = kResolvedPromise;
-  } else {
-    result = PromiseResolve(result);
+    return kResolvedPromise;
   }
+  result = PromiseResolve(result);
   controllerState.performTransformRejected ??= (error) => {
     transformStreamError(controller[kState].stream, error);
     throw error;