Skip to content

Commit

Permalink
fix: send an empty response to acknowledge the webhook call
Browse files Browse the repository at this point in the history
  • Loading branch information
AlasDiablo committed May 6, 2024
1 parent ea85f70 commit d8e3739
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions tdm-be/src/controller/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ router.post(
return;
}

enrichmentHook.success(id);
enrichmentHook.success(id).then(undefined);
res.send();
},
(error) => {
logger.error(error);
Expand All @@ -39,7 +40,8 @@ router.post(
return;
}

enrichmentHook.failure(id);
enrichmentHook.failure(id).then(undefined);
res.send();
},
(error) => {
logger.error(error);
Expand Down
13 changes: 8 additions & 5 deletions tdm-be/src/worker/enrichmentHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ const enrichmentHookFailure = async (processingId: string) => {
};

const catchEnrichmentHook = (enrichmentHook: { (processingId: string): Promise<void> }) => {
return (processingId: string) => {
const enrichmentPromise = enrichmentHook(processingId);
enrichmentPromise.catch((e) => {
return async (processingId: string) => {
try {
await enrichmentHook(processingId);
} catch (e) {
const message = 'Receive an un-catch error from enrichment hook';
error(processingId, 'Receive an un-catch error from enrichment hook');
crash(e, message, processingId);
Expand All @@ -222,8 +223,10 @@ const catchEnrichmentHook = (enrichmentHook: { (processingId: string): Promise<v
return;
}
errorEmail(processing, ERROR_MESSAGE_ENRICHMENT_HOOK_UNEXPECTED_ERROR);
} catch (ignored) {}
});
} catch (ignored) {
/* empty */
}
}
};
};

Expand Down

0 comments on commit d8e3739

Please sign in to comment.