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

StatusPageAPI doesn't handle error events #7

Open
jutaz opened this issue Mar 5, 2018 · 0 comments
Open

StatusPageAPI doesn't handle error events #7

jutaz opened this issue Mar 5, 2018 · 0 comments

Comments

@jutaz
Copy link

jutaz commented Mar 5, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant