Commit 08535906dcd3e208b0071ad41c7daf72f3b68421

Authored by Adhidarma Hadiwinoto
1 parent c9e2c47ff2
Exists in master

different last dump filename for each webhook type

Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff

lib/webhook-sender.js
... ... @@ -17,10 +17,10 @@ const sleepBeforeRetryMs = Number(config.webhook && config.webhook.sleep_before_
17 17 || DEFAULT_SLEEP_BEFORE_RETRY_MS;
18 18  
19 19 const baseDumpDir = path.join('dump', 'webhook-sender');
  20 +
20 21 if (!fs.existsSync(baseDumpDir)) {
21 22 fs.mkdirSync(baseDumpDir, { recursive: true });
22 23 }
23   -const lastDumpFileName = path.join(baseDumpDir, 'last.json');
24 24  
25 25 const sleepMs = (ms) => new Promise((resolve) => {
26 26 setTimeout(() => {
... ... @@ -41,13 +41,15 @@ const dumper = async (xid, webhookType, body) => {
41 41 'json',
42 42 ].filter((item) => item).join('.');
43 43  
  44 + // write dump file
44 45 await fs.promises.writeFile(
45 46 path.join(baseDumpDir, filename),
46 47 stringify({ webhookType, body }),
47 48 );
48 49  
  50 + // write last dump file
49 51 await fs.promises.writeFile(
50   - lastDumpFileName,
  52 + path.join(baseDumpDir, ['last', webhookType].join('.')),
51 53 stringify({ webhookType, body }),
52 54 );
53 55 } catch (e) {