Skip to content

Promises: Unhandled rejections #32

Description

@frankebersoll

One big issue with exception handling in JavaScript is Promises: When you don't explicitly handle an error using a rejection callback, most Promise libraries provide global events like Promise.onPossiblyUnhandledRejection (bluebird.js), Q.getUnhandledReasons (Q.js) or process.on('unhandledRejection) (Node.js). Not subscribing to those events when using Promises probably contributes to many programmer errors staying unnoticed, as the application won't neccessarily terminate.

It would be cool if Exceptionless.js checked for the existence of such modules and events and created handlers that automatically submit the exceptions. While we do that, we should refactor all global exception handlers into implementations of an interface that can be added to the configuration like plugins.

Name proposals:

  • IGlobalExceptionHandler
  • IExceptionHook
  • IExceptionSource

Activity

  1. ejsmith commented on Oct 11, 2015

    @ejsmith
    Member

    Seems like this can just be plugins for each technology. So you would wire up to Promise.onPossiblyUnhandledRejection and then submit the event from inside the handler. We are already doing something very similar here:

    https://github.com/exceptionless/Exceptionless.JavaScript/blob/master/src/integrations/angular.ts

  2. self-assigned this
    on Feb 22, 2023
  3. added a commit that references this issue on Feb 22, 2023
    2eba9b9
  4. niemyjski commented on Feb 22, 2023

    @niemyjski
    Member

    The 2.0 client had support for unhandled rejections but I added an example and uncovered a few issues around types... you can reject anything. We now properly handle converting unknown types to error objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions