Merge pull request #2107 from github/revert-2076-robertbrignull/unhandled_rejection
Revert "Add unhandled rejection listener"
This commit is contained in:
@@ -234,7 +234,6 @@ export async function activate(
|
|||||||
const distributionConfigListener = new DistributionConfigListener();
|
const distributionConfigListener = new DistributionConfigListener();
|
||||||
await initializeLogging(ctx);
|
await initializeLogging(ctx);
|
||||||
await initializeTelemetry(extension, ctx);
|
await initializeTelemetry(extension, ctx);
|
||||||
addUnhandledRejectionListener();
|
|
||||||
install();
|
install();
|
||||||
|
|
||||||
const codelensProvider = new QuickEvalCodeLensProvider();
|
const codelensProvider = new QuickEvalCodeLensProvider();
|
||||||
@@ -1526,35 +1525,6 @@ async function activateWithInstalledDistribution(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function addUnhandledRejectionListener() {
|
|
||||||
const handler = (error: unknown) => {
|
|
||||||
const message = redactableError(
|
|
||||||
asError(error),
|
|
||||||
)`Unhandled error: ${getErrorMessage(error)}`;
|
|
||||||
// Add a catch so that showAndLogExceptionWithTelemetry fails, we avoid
|
|
||||||
// triggering "unhandledRejection" and avoid an infinite loop
|
|
||||||
showAndLogExceptionWithTelemetry(message).catch(
|
|
||||||
(telemetryError: unknown) => {
|
|
||||||
void extLogger.log(
|
|
||||||
`Failed to send error telemetry: ${getErrorMessage(telemetryError)}`,
|
|
||||||
);
|
|
||||||
void extLogger.log(message.fullMessage);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// "uncaughtException" will trigger whenever an exception reaches the top level.
|
|
||||||
// This covers extension initialization and any code within a `setTimeout`.
|
|
||||||
// Notably this does not include exceptions thrown when executing commands,
|
|
||||||
// because `commandRunner` wraps the command body and handles errors.
|
|
||||||
process.addListener("uncaughtException", handler);
|
|
||||||
|
|
||||||
// "unhandledRejection" will trigger whenever any promise is rejected and it is
|
|
||||||
// not handled by a "catch" somewhere in the promise chain. This includes when
|
|
||||||
// a promise is used with the "void" operator.
|
|
||||||
process.addListener("unhandledRejection", handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createQueryServer(
|
async function createQueryServer(
|
||||||
qlConfigurationListener: QueryServerConfigListener,
|
qlConfigurationListener: QueryServerConfigListener,
|
||||||
cliServer: CodeQLCliServer,
|
cliServer: CodeQLCliServer,
|
||||||
|
|||||||
Reference in New Issue
Block a user