UNPKG

@sentry/node

Version:

Sentry Node SDK using OpenTelemetry for performance instrumentation

33 lines (32 loc) • 1.07 kB
import { DEBUG_BUILD } from "../debug-build.js"; import { consoleSandbox, debug, getClient } from "@sentry/core"; // src/utils/errorhandling.ts const DEFAULT_SHUTDOWN_TIMEOUT = 2e3; let isShuttingDown = false; /** * @hidden */ 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); }, (error) => { DEBUG_BUILD && debug.error(error); global.process.exit(1); }); } export { logAndExitProcess }; //# sourceMappingURL=errorhandling.js.map