Commit 62fcc778ca0ccd958f7687cbfa312dce8cf4bae4

Authored by Adhidarma Hadiwinoto
1 parent 485b7af4bb
Exists in master

Debug

Showing 1 changed file with 18 additions and 10 deletions Side-by-side Diff

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) => {
... ... @@ -89,7 +97,7 @@ const sender = async (xid, webhookType, body, retry) => {
89 97 }
90 98  
91 99 await sleepMs(sleepBeforeRetryMs);
92   - sender(xid, webhookType, body, (retry || 0) + 1);
  100 + await sender(xid, webhookType, body, (retry || 0) + 1);
93 101 }
94 102 };
95 103 module.exports = sender;