server: fix cpu loop on SIGPIPE (#170305)

- One missed uncaughtException site was causing a loop (maybe we want
  to handle this error on onUnexpectedError instead?)
- The SIGPIPE listener itself was causing a loop, as well. Only try to log once.
This commit is contained in:
Connor Peet
2023-01-17 11:25:58 -08:00
committed by GitHub
parent cc65c347df
commit dec4735ed6
6 changed files with 42 additions and 10 deletions
+6 -2
View File
@@ -7,7 +7,7 @@ import { hostname, release } from 'os';
import { raceTimeout } from 'vs/base/common/async';
import { VSBuffer } from 'vs/base/common/buffer';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { onUnexpectedError, setUnexpectedErrorHandler } from 'vs/base/common/errors';
import { isSigPipeError, onUnexpectedError, setUnexpectedErrorHandler } from 'vs/base/common/errors';
import { Disposable } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import { isAbsolute, join } from 'vs/base/common/path';
@@ -242,7 +242,11 @@ class CliMain extends Disposable {
});
// Handle unhandled errors that can occur
process.on('uncaughtException', err => onUnexpectedError(err));
process.on('uncaughtException', err => {
if (!isSigPipeError(err)) {
onUnexpectedError(err);
}
});
process.on('unhandledRejection', (reason: unknown) => onUnexpectedError(reason));
}