Skip to content

StatusPageAPI doesn't handle error events #7

@jutaz

Description

@jutaz

StatusPageAPI class' methods create StatusPageRequest, which emits error events, but those aren't handled in class' methods.

This leads to a problem if statuspage API is unreachable (or any other error in TCP stack), which happened just last week - since error event isn't handled, it's propagated to the topmost process' scope. This leaves clients with 2 possibilities - handle error via process.on('unhandledException', () => {}) or crash.

In some (maybe most) cases handling such exceptions via process.on('unhandledException', () => {}) is undesirable due to difficulty of understanding where the error originated from etc.

There is a possibility to handle such errors with (now deprecated) domain package module internally, but given it's depreciation - it's not a great option either.

How to reproduce

const StatusPage = require('statuspage-api'),
      api = new StatusPage({
        pageid: 'id',
        apikey: 'key',
        host: 'someNonReachableHost.tld'
      });

api.get('components', (result) => {
  // Will never get called - global exception will occur.
});

I'm happy to submit a patch to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions