1
0
Fork 0
mirror of https://github.com/Jackett/Jackett synced 2024-12-23 08:17:25 +00:00

Update redeliver-failed-deliveries.js

This commit is contained in:
garfield69 2024-01-25 17:10:57 +13:00 committed by GitHub
parent 540dbb012a
commit 05889ad7e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,9 @@
// This script uses GitHub's Octokit SDK to make API requests. For more information, see "[AUTOTITLE](/rest/guides/scripting-with-the-rest-api-and-javascript)." // This script uses GitHub's Octokit SDK to make API requests. For more information, see "[AUTOTITLE](/rest/guides/scripting-with-the-rest-api-and-javascript)."
const { App, Octokit } = require("octokit"); const { App, Octokit } = require("octokit");
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
const secondDelivery = true;
// //
async function checkAndRedeliverWebhooks() { async function checkAndRedeliverWebhooks() {
// Get the values of environment variables that were set by the GitHub Actions workflow. // Get the values of environment variables that were set by the GitHub Actions workflow.
@ -69,6 +72,13 @@ async function checkAndRedeliverWebhooks() {
// Redeliver any failed deliveries. // Redeliver any failed deliveries.
for (const deliveryId of failedDeliveryIDs) { for (const deliveryId of failedDeliveryIDs) {
await redeliverWebhook({deliveryId, app}); await redeliverWebhook({deliveryId, app});
// its likely ProBot was asleep when the first redeliver was sent and we know PRoBot startup takes about 12s
// so the first redeliver will likely timeout after 10s, but will have started ProBot
if (secondDelivery) {
secondDelivery = false;
// so we wait 13s so that the rest of the redeliveries will succeed
await sleep(13000);
}
} }
// Update the configuration variable (or create the variable if it doesn't already exist) to store the time that this script started. // Update the configuration variable (or create the variable if it doesn't already exist) to store the time that this script started.