diff --git a/node/internal.ts b/node/internal.ts index d7c776aef..3b57b7261 100644 --- a/node/internal.ts +++ b/node/internal.ts @@ -1060,3 +1060,11 @@ function _exposeTaskLibSecret(keyFile: string, secret: string): string | undefin return new Buffer(storageFile).toString('base64') + ':' + new Buffer(encryptedContent).toString('base64'); } } + +export function isSigPipeError(e: NodeJS.ErrnoException): e is NodeJS.ErrnoException { + if (!e || typeof e !== 'object') { + return false; + } + + return e.code === 'EPIPE' && e.syscall?.toUpperCase() === 'WRITE'; +} \ No newline at end of file diff --git a/node/task.ts b/node/task.ts index cfa22927a..2ecd05f73 100644 --- a/node/task.ts +++ b/node/task.ts @@ -126,8 +126,10 @@ export function setSanitizedResult(result: TaskResult, message: string, done?: b // Catching all exceptions // process.on('uncaughtException', (err: Error) => { - setResult(TaskResult.Failed, loc('LIB_UnhandledEx', err.message)); - error(String(err.stack), im.IssueSource.TaskInternal); + if (!im.isSigPipeError(err)) { + setResult(TaskResult.Failed, loc('LIB_UnhandledEx', err.message)); + error(String(err.stack), im.IssueSource.TaskInternal); + } }); // diff --git a/node/toolrunner.ts b/node/toolrunner.ts index 48dcc2b73..65695b986 100644 --- a/node/toolrunner.ts +++ b/node/toolrunner.ts @@ -671,7 +671,13 @@ 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 { @@ -870,6 +876,12 @@ 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 {