Compare View

switch
from
...
to
 
Commits (2)

Changes

Showing 2 changed files Side-by-side Diff

lib/core-callback/sender.js
... ... @@ -73,8 +73,14 @@ const sender = async (data, xid, retry) => {
73 73 const isPostpaid = ['INQUIRY', 'PAY'].indexOf(data.command) >= 0;
74 74 const isHttpPost = isPostpaid;
75 75  
76   - const webhookType = 'KOMODO-CENTER-HTTPGETX.CORE-CALLBACK';
77   - webhookSender(xid, webhookType, params);
  76 + try {
  77 + const webhookType = 'KOMODO-CENTER-HTTPGETX.CORE-CALLBACK';
  78 + webhookSender(xid, webhookType, params);
  79 + } catch (e) {
  80 + logger.warn(`${MODULE_NAME} 1E2BF2CD: Exception calling webhookSender`, {
  81 + xid,
  82 + });
  83 + }
78 84  
79 85 if (!data.reverse_url) {
80 86 logger.verbose(`${MODULE_NAME} C4FF18FB: Ignoring missing reverse url`, {
lib/webhook-sender.js
... ... @@ -33,15 +33,23 @@ const dumper = async (xid, webhookType, body) => {
33 33 return;
34 34 }
35 35  
36   - await fs.promises.writeFile(
37   - path.join(baseDumpDir, [moment().format('YYYYMMDD-HHmmssSSS'), xid].join('_')),
38   - stringify({ webhookType, body }),
39   - );
40   -
41   - await fs.promises.writeFile(
42   - lastDumpFileName,
43   - stringify({ webhookType, body }),
44   - );
  36 + try {
  37 + await fs.promises.writeFile(
  38 + path.join(baseDumpDir, [moment().format('YYYYMMDD-HHmmssSSS'), xid].join('_')),
  39 + stringify({ webhookType, body }),
  40 + );
  41 +
  42 + await fs.promises.writeFile(
  43 + lastDumpFileName,
  44 + stringify({ webhookType, body }),
  45 + );
  46 + } catch (e) {
  47 + logger.warn(`${MODULE_NAME} D3EF00D9: Exception on dumper`, {
  48 + xid,
  49 + eCode: e.code,
  50 + eMessage: e.message || e.toString(),
  51 + });
  52 + }
45 53 };
46 54  
47 55 const sender = async (xid, webhookType, body, retry) => {
... ... @@ -73,6 +81,7 @@ const sender = async (xid, webhookType, body, retry) => {
73 81 } catch (e) {
74 82 logger.warn(`${MODULE_NAME} ECC37ECA: Exception on calling webhook`, {
75 83 xid,
  84 + httpStatusCode: e.response && e.response.status,
76 85 eCode: e.code,
77 86 eMessage: e.message || e.toString(),
78 87 retried: retry || 0,
... ... @@ -88,7 +97,7 @@ const sender = async (xid, webhookType, body, retry) => {
88 97 }
89 98  
90 99 await sleepMs(sleepBeforeRetryMs);
91   - sender(xid, webhookType, body, (retry || 0) + 1);
  100 + await sender(xid, webhookType, body, (retry || 0) + 1);
92 101 }
93 102 };
94 103 module.exports = sender;