Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix --abort-on-uncaught-exception #3036

Closed

Commits on Oct 5, 2015

  1. deps: backport 1ee712a from V8 upstream

    Backport 1ee712ab8687e5f4dec93d45da068d37d28feb8b from V8 upstream.
    
    Original commit message:
    
      Add SetAbortOnUncaughtExceptionCallback API
    
      The --abort-on-uncaught-exception command line switch makes
      Isolate::Throw abort if the error being thrown cannot be caught by a
      try/catch block.
    
      Embedders may want to use other mechanisms than try/catch blocks to
      handle uncaught exceptions. For instance, Node.js has "domain" objects
      that have error handlers that can handle uncaught exception like
      following:
    
      var d = domain.create();
    
      d.on('error', function onError(err) {
        console.log('Handling error');
      });
    
      d.run(function() {
        throw new Error("boom");
      });
    
      These error handlers are called by isolates' message listeners.
    
      If --abort-on-uncaught-exception is *not* used, the isolate's
      message listener will be called, which will in turn call the domain's
      error handler. The process will output 'Handling error' and will exit
      successfully (not due to an uncaught exception). This is the behavior
      that Node.js users expect.
    
      However, if --abort-on-uncaught-exception is used and when throwing an
      error within a domain that has an error handler, the process will abort
      and the domain's error handler will not be called. This is not the
      behavior that Node.js users expect.
    
      Having a SetAbortOnUncaughtExceptionCallback API allows embedders to
      determine when it's not appropriate to abort and instead handle the
      exception via the isolate's message listener.
    
      In the example above, Node.js would set a custom callback with
      SetAbortOnUncaughtExceptionCallback that would be implemented as
      following (the sample code has been simplified to remove what's not
      relevant to this change):
    
      bool ShouldAbortOnUncaughtException(Isolate* isolate) {
        return !IsDomainActive();
      }
    
      Now when --abort-on-uncaught-exception is used, Isolate::Throw would
      call that callback and determine that it should not abort if a domain
      with an error handler is active. Instead, the isolate's message listener
      would be called and the error would be handled by the domain's error
      handler.
    
      I believe this can also be useful for other embedders.
    
      BUG=
    
      R=bmeurer@chromium.org
    
      Review URL: https://codereview.chromium.org/1375933003
    
      Cr-Commit-Position: refs/heads/master@{nodejs#31111}
    Julien Gilli committed Oct 5, 2015
    Configuration menu
    Copy the full SHA
    ffb1843 View commit details
    Browse the repository at this point in the history
  2. src: fix --abort-on-uncaught-exception

    Revert 0af4c9e, parts of
    921f2de and port
    nodejs/node-v0.x-archive#25835 from v0.12 to
    master so that node aborts at the right time when an error is thrown
    and --abort-on-uncaught-exception is used.
    
    Fixes nodejs#3035.
    whitlockjc authored and Julien Gilli committed Oct 5, 2015
    Configuration menu
    Copy the full SHA
    9dbd755 View commit details
    Browse the repository at this point in the history