-
Notifications
You must be signed in to change notification settings - Fork 12
Description
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.