From 99b62c81c7bb1f0fd66ac358a31df348d0b5a5df Mon Sep 17 00:00:00 2001 From: Madala Sai Deekshitha Date: Wed, 22 Oct 2025 10:23:16 +0530 Subject: [PATCH 1/3] unskipping the test cases --- node/test/toolrunnerTestsWithExecAsync.ts | 2 +- node/test/toolrunnertests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/test/toolrunnerTestsWithExecAsync.ts b/node/test/toolrunnerTestsWithExecAsync.ts index 9271ba45c..e58fce359 100644 --- a/node/test/toolrunnerTestsWithExecAsync.ts +++ b/node/test/toolrunnerTestsWithExecAsync.ts @@ -951,7 +951,7 @@ describe('Toolrunner Tests With ExecAsync', function () { }) } }) - it.skip('Exec pipe output to file and another tool, fails if second tool fails', function (done) { + it('Exec pipe output to file and another tool, fails if second tool fails', function (done) { this.timeout(20000); var _testExecOptions = { diff --git a/node/test/toolrunnertests.ts b/node/test/toolrunnertests.ts index 146c79465..e7f2b8434 100644 --- a/node/test/toolrunnertests.ts +++ b/node/test/toolrunnertests.ts @@ -1101,7 +1101,7 @@ describe('Toolrunner Tests', function () { }) } }) - it.skip('Exec pipe output to file and another tool, fails if second tool fails', function (done) { + it('Exec pipe output to file and another tool, fails if second tool fails', function (done) { this.timeout(20000); var _testExecOptions = { From 4b6ad93dfc22b4dcea62565fbbfd14cceb6451e0 Mon Sep 17 00:00:00 2001 From: Madala Sai Deekshitha Date: Fri, 24 Oct 2025 07:04:42 +0530 Subject: [PATCH 2/3] error handling for EPIPE --- node/toolrunner.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/node/toolrunner.ts b/node/toolrunner.ts index 17e102610..ad6b6e103 100644 --- a/node/toolrunner.ts +++ b/node/toolrunner.ts @@ -671,6 +671,11 @@ export class ToolRunner extends events.EventEmitter { }); } + cp.stdin?.on("error", (err: Error) => { + if (!im.isSigPipeError(err)) { + throw err; + } + }); //pipe stdout of first tool to stdin of second tool cpFirst.stdout?.on('data', (data: Buffer) => { try { @@ -871,6 +876,11 @@ export class ToolRunner extends events.EventEmitter { }); } + cp.stdin?.on("error", (err: Error) => { + if (!im.isSigPipeError(err)) { + throw err; + } + }); //pipe stdout of first tool to stdin of second tool cpFirst.stdout?.on('data', (data: Buffer) => { try { From 904a2863e503fce92f6c22d2300a14c9398084b2 Mon Sep 17 00:00:00 2001 From: Madala Sai Deekshitha Date: Fri, 24 Oct 2025 14:49:50 +0530 Subject: [PATCH 3/3] error handling for EPIPE --- node/toolrunner.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/node/toolrunner.ts b/node/toolrunner.ts index ad6b6e103..8f2448b74 100644 --- a/node/toolrunner.ts +++ b/node/toolrunner.ts @@ -671,18 +671,20 @@ export class ToolRunner extends events.EventEmitter { }); } + let stdinEpipe = false; cp.stdin?.on("error", (err: Error) => { - if (!im.isSigPipeError(err)) { - throw err; - } - }); + if (!im.isSigPipeError(err)) { + throw err; + } + stdinEpipe = true; + }); //pipe stdout of first tool to stdin of second tool cpFirst.stdout?.on('data', (data: Buffer) => { try { if (fileStream) { fileStream.write(data); } - if (!cp.stdin?.destroyed) { + if (!cp.stdin?.destroyed && !cp.stdin?.writableEnded && !stdinEpipe) { cp.stdin?.write(data); } } catch (err) { @@ -876,10 +878,12 @@ export class ToolRunner extends events.EventEmitter { }); } + let stdinEpipe = false; cp.stdin?.on("error", (err: Error) => { if (!im.isSigPipeError(err)) { throw err; } + stdinEpipe = true; }); //pipe stdout of first tool to stdin of second tool cpFirst.stdout?.on('data', (data: Buffer) => { @@ -887,7 +891,9 @@ export class ToolRunner extends events.EventEmitter { if (fileStream) { fileStream.write(data); } - cp.stdin?.write(data); + if (!cp.stdin?.destroyed && !cp.stdin?.writableEnded && !stdinEpipe) { + cp.stdin?.write(data); + } } catch (err) { this._debug('Failed to pipe output of ' + toolPathFirst + ' to ' + toolPath); this._debug(toolPath + ' might have exited due to errors prematurely. Verify the arguments passed are valid.');