Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
fix: send response for cleared requests
Browse files Browse the repository at this point in the history
  • Loading branch information
feerglas committed Jul 30, 2021
1 parent 0bef4c8 commit f66b4aa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const triggerTravisJob = (commit, response) => {

let pendingTimeout = false;
let pendingCommitMessage = '';
let pendingResponse = false;
const pendingDuration = 15 * 1000;

const triggerTravisJobDelayed = (commit, response) => {
Expand All @@ -93,13 +94,19 @@ const triggerTravisJobDelayed = (commit, response) => {
clearTimeout(pendingTimeout);
}

if (pendingResponse) {
pendingResponse.sendStatus(200);
}

pendingResponse = response;

if (commit.length > 0) {
pendingCommitMessage = commit;
}

pendingTimeout = setTimeout(() => {
console.log(`FIGMA-LISTENER: -->> Webhook from Figma received. Waiting for ${pendingDuration} to see if another request comes in.`);
triggerTravisJob(pendingCommitMessage, response);
triggerTravisJob(pendingCommitMessage, pendingResponse);

pendingTimeout = false;
pendingCommitMessage = '';
Expand Down

0 comments on commit f66b4aa

Please sign in to comment.