From 5e316499e580cd0384983ba1bb8159f0d8b7739a Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 7 Feb 2026 18:01:33 +0900 Subject: [PATCH] fix: explicitly pass encoding/callback args through stdout.write wrapper --- src/cli/run/json-output.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cli/run/json-output.ts b/src/cli/run/json-output.ts index a4b2e109..caed9e02 100644 --- a/src/cli/run/json-output.ts +++ b/src/cli/run/json-output.ts @@ -20,8 +20,18 @@ export function createJsonOutputManager( const originalWrite = stdout.write.bind(stdout) function redirectToStderr(): void { - stdout.write = function (...args: Parameters): boolean { - return (stderr.write as Function).apply(stderr, args) + stdout.write = function ( + chunk: Uint8Array | string, + encodingOrCallback?: BufferEncoding | ((error?: Error | null) => void), + callback?: (error?: Error | null) => void + ): boolean { + if (typeof encodingOrCallback === "function") { + return stderr.write(chunk, encodingOrCallback) + } + if (encodingOrCallback !== undefined) { + return stderr.write(chunk, encodingOrCallback, callback) + } + return stderr.write(chunk) } as NodeJS.WriteStream["write"] }