errorhandling.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. Object.defineProperty(exports, '__esModule', { value: true });
  2. const core = require('@sentry/core');
  3. const utils = require('@sentry/utils');
  4. const debugBuild = require('../../debug-build.js');
  5. const DEFAULT_SHUTDOWN_TIMEOUT = 2000;
  6. /**
  7. * @hidden
  8. */
  9. function logAndExitProcess(error) {
  10. utils.consoleSandbox(() => {
  11. // eslint-disable-next-line no-console
  12. console.error(error);
  13. });
  14. const client = core.getClient();
  15. if (client === undefined) {
  16. debugBuild.DEBUG_BUILD && utils.logger.warn('No NodeClient was defined, we are exiting the process now.');
  17. global.process.exit(1);
  18. }
  19. const options = client.getOptions();
  20. const timeout =
  21. (options && options.shutdownTimeout && options.shutdownTimeout > 0 && options.shutdownTimeout) ||
  22. DEFAULT_SHUTDOWN_TIMEOUT;
  23. client.close(timeout).then(
  24. (result) => {
  25. if (!result) {
  26. debugBuild.DEBUG_BUILD && utils.logger.warn('We reached the timeout for emptying the request buffer, still exiting now!');
  27. }
  28. global.process.exit(1);
  29. },
  30. error => {
  31. debugBuild.DEBUG_BUILD && utils.logger.error(error);
  32. },
  33. );
  34. }
  35. exports.logAndExitProcess = logAndExitProcess;
  36. //# sourceMappingURL=errorhandling.js.map