How to use the promise/setimmediate/rejection-tracking.disable function in promise

To help you get started, we’ve selected a few promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getsentry / sentry-react-native / src / js / integrations / reactnativeerrorhandlers.ts View on Github external
private _handleUnhandledRejections(): void {
    if (this._options.onunhandledrejection) {
      // tslint:disable-next-line: no-implicit-dependencies
      const tracking = require("promise/setimmediate/rejection-tracking");
      tracking.disable();
      tracking.enable({
        allRejections: true,
        onHandled: () => {
          // We do nothing
        },
        onUnhandled: (id: any, error: any) => {
          getCurrentHub().captureException(error, {
            data: { id },
            originalException: error
          });
        }
      });
    }
  }
github getsentry / sentry-react-native / lib / raven-plugin.js View on Github external
}

  // Make sure that if multiple fatals occur, we only persist the first one.
  //
  // The first error is probably the most important/interesting error, and we
  // want to crash ASAP, rather than potentially queueing up multiple errors.
  var handlingFatal = false;

  var defaultHandler =
    (ErrorUtils.getGlobalHandler && ErrorUtils.getGlobalHandler()) ||
    ErrorUtils._globalHandler;

  if (options.handlePromiseRejection) {
    // Track unhandled promise rejections
    var tracking = require('promise/setimmediate/rejection-tracking');
    tracking.disable();
    tracking.enable({
      allRejections: true,
      onUnhandled: function(id, error) {
        var captureOptions = {
          timestamp: new Date() / 1000,
          type: 'Unhandled Promise Rejection'
        };
        Raven.captureException(error, captureOptions);
      },
      onHandled: function() {}
    });
  }

  ErrorUtils.setGlobalHandler(function(error, isFatal) {
    var captureOptions = {
      timestamp: new Date() / 1000
github getsentry / sentry-react-native / src / js / integrations / reactnative.ts View on Github external
private _handleUnhandledRejections(): void {
    if (this._options.onunhandledrejection) {
      const tracking = require("promise/setimmediate/rejection-tracking");
      tracking.disable();
      tracking.enable({
        allRejections: true,
        onUnhandled: (id: any, error: any) => {
          console.log(id, error);
        },
        onHandled: function() {}
      });
    }
  }