Skip to content

Commit de6f74d

Browse files
Kartik RajDonJayamanne
Kartik Raj
andauthored
stream error handler to prevent proc from exiting (#15446) (#15596)
Co-authored-by: Don Jayamanne <don.jayamanne@yahoo.com>
1 parent 08565f1 commit de6f74d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

news/2 Fixes/15395.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add event handlers to stream error events to prevent process from exiting due to errors in process stdout & stderr streams.

src/client/common/process/rawProcessApis.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
SpawnOptions,
1818
StdErrError,
1919
} from './types';
20+
import { noop } from '../utils/misc';
2021

2122
export function getDefaultOptions<T extends ShellOptions | SpawnOptions>(
2223
options: T,
@@ -98,6 +99,10 @@ export function plainExec(
9899
const spawnOptions = getDefaultOptions(options, defaultEnv);
99100
const encoding = spawnOptions.encoding ? spawnOptions.encoding : 'utf8';
100101
const proc = spawn(file, args, spawnOptions);
102+
// Listen to these errors (unhandled errors in streams tears down the process).
103+
// Errors will be bubbled up to the `error` event in `proc`, hence no need to log.
104+
proc.stdout?.on('error', noop);
105+
proc.stderr?.on('error', noop);
101106
const deferred = createDeferred<ExecutionResult<string>>();
102107
const disposable: IDisposable = {
103108
dispose: () => {

0 commit comments

Comments
 (0)