Fix unhandled promiss rejection when sending a notification fails and add eslint check
This MR:
- fixes a bug when sending a notification to an apprise server fails (first commit, see STR below)
- activate the appropriate eslint rule and fix found 'orphan' promises.
STR :
- Configure a dummy server for apprise. e.g., in the config.ini, set
appriseApiBaseUrl = localhost:8000
- Activate the notifications (or an alert).
- Trigger the emission of the notification (failed fetch for example)
The following error happens:
node:264869) UnhandledPromiseRejectionWarning: FetchError: request to http://localhost:8000/notify failed, reason: connect ECONNREFUSED 127.0.0.1:8000
[5] at ClientRequest.<anonymous> (/home/tonio/Code/kresus/node_modules/node-fetch/lib/index.js:1461:11)
[5] at ClientRequest.emit (events.js:315:20)
[5] at Socket.socketErrorListener (_http_client.js:469:9)
[5] at Socket.emit (events.js:315:20)
[5] at emitErrorNT (internal/streams/destroy.js:106:8)
[5] at emitErrorCloseNT (internal/streams/destroy.js:74:3)
[5] at processTicksAndRejections (internal/process/task_queues.js:80:21)
[5] (Use `node --trace-warnings ...` to show where the warning was created)
[5] (node:264869) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
After thie fix:
[2020-12-11T21:20:39.366] [ERROR] poller - when sending an alert to warn about polling errors: request to http://localhost:8000/notify failed, reason: connect ECONNREFUSED 127.0.0.1:8000
Edited by Antoine