@sentry/node
Version:
Sentry Node SDK using OpenTelemetry for performance instrumentation
38 lines (35 loc) • 1.1 kB
JavaScript
import { consoleSandbox, getClient, debug } from '@sentry/core';
import { DEBUG_BUILD } from '../debug-build.js';
const DEFAULT_SHUTDOWN_TIMEOUT = 2e3;
let isShuttingDown = false;
function logAndExitProcess(error) {
if (isShuttingDown) {
return;
}
isShuttingDown = true;
consoleSandbox(() => {
console.error(error);
});
const client = getClient();
if (client === void 0) {
DEBUG_BUILD && debug.warn("No NodeClient was defined, we are exiting the process now.");
global.process.exit(1);
return;
}
const options = client.getOptions();
const timeout = options?.shutdownTimeout && options.shutdownTimeout > 0 ? options.shutdownTimeout : DEFAULT_SHUTDOWN_TIMEOUT;
client.close(timeout).then(
(result) => {
if (!result) {
DEBUG_BUILD && debug.warn("We reached the timeout for emptying the request buffer, still exiting now!");
}
global.process.exit(1);
},
(error2) => {
DEBUG_BUILD && debug.error(error2);
global.process.exit(1);
}
);
}
export { logAndExitProcess };
//# sourceMappingURL=errorhandling.js.map