From e5c209e26989cab64e113c150d72debf7503acef Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Sat, 5 Nov 2022 10:27:00 -0400 Subject: [PATCH] fix for #186: unhandled error when amd webhook returns non-success status code --- lib/tasks/config.js | 6 +++++- lib/tasks/dial.js | 5 ++++- lib/utils/http-listener.js | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/tasks/config.js b/lib/tasks/config.js index 2c84665b..e2d1fd31 100644 --- a/lib/tasks/config.js +++ b/lib/tasks/config.js @@ -146,7 +146,11 @@ class TaskConfig extends Task { _onAmdEvent(cs, evt) { this.logger.info({evt}, 'Config:_onAmdEvent'); const {actionHook} = this.data.amd; - this.performHook(cs, actionHook, evt); + this.performHook(cs, actionHook, evt) + .catch((err) => { + this.logger.error({err}, 'Config:_onAmdEvent - error calling actionHook'); + }); + } } diff --git a/lib/tasks/dial.js b/lib/tasks/dial.js index 76eaa483..2fa32534 100644 --- a/lib/tasks/dial.js +++ b/lib/tasks/dial.js @@ -689,7 +689,10 @@ class TaskDial extends Task { _onAmdEvent(cs, evt) { this.logger.info({evt}, 'Dial:_onAmdEvent'); const {actionHook} = this.data.amd; - this.performHook(cs, actionHook, evt); + this.performHook(cs, actionHook, evt) + .catch((err) => { + this.logger.error({err}, 'Dial:_onAmdEvent - error calling actionHook'); + }); } } diff --git a/lib/utils/http-listener.js b/lib/utils/http-listener.js index f9fd9e61..5674b418 100644 --- a/lib/utils/http-listener.js +++ b/lib/utils/http-listener.js @@ -21,6 +21,7 @@ const handleErrors = (logger, app, resolve, reject, e) => { server.on('error', handleErrors.bind(null, logger, app, resolve, reject)); return; } + logger.info({err: e, port: PORT}, 'httpListener error'); reject(e); }; @@ -30,7 +31,7 @@ const createHttpListener = (logger, srf) => { app.use(express.urlencoded({ extended: true })); app.use(express.json()); app.use('/', httpRoutes); - app.use((err, req, res, next) => { + app.use((err, _req, res, _next) => { logger.error(err, 'burped error'); res.status(err.status || 500).json({msg: err.message}); });