Fix webhook queue processing with automatic polling
- Call webhook_process endpoint when loading queue status - Add automatic polling every 10 seconds when webhooks are pending - Stop polling automatically when queue is empty - Ensures debounced webhooks actually fire when due Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -694,15 +694,28 @@ async function triggerWebhookNow() {
|
||||
}
|
||||
}
|
||||
|
||||
// Webhook queue polling interval
|
||||
let webhookQueueInterval = null;
|
||||
|
||||
// Load webhook queue status
|
||||
async function loadWebhookQueueStatus() {
|
||||
const container = document.getElementById('webhookQueueContainer');
|
||||
|
||||
try {
|
||||
// First, trigger processing of any due webhooks
|
||||
await api('webhook_process');
|
||||
|
||||
const result = await api('webhook_queue_status');
|
||||
|
||||
if (result.success) {
|
||||
renderWebhookQueueStatus(result.data);
|
||||
|
||||
// Set up auto-refresh if there are pending webhooks
|
||||
if (result.data.counts.pending > 0) {
|
||||
startWebhookQueuePolling();
|
||||
} else {
|
||||
stopWebhookQueuePolling();
|
||||
}
|
||||
} else {
|
||||
container.innerHTML = '<p style="color: var(--text-secondary);">Failed to load queue status</p>';
|
||||
}
|
||||
@@ -711,6 +724,35 @@ async function loadWebhookQueueStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
// Start polling for webhook queue updates
|
||||
function startWebhookQueuePolling() {
|
||||
if (webhookQueueInterval) return; // Already polling
|
||||
|
||||
webhookQueueInterval = setInterval(async () => {
|
||||
// Process any due webhooks
|
||||
await api('webhook_process');
|
||||
|
||||
// Reload status
|
||||
const result = await api('webhook_queue_status');
|
||||
if (result.success) {
|
||||
renderWebhookQueueStatus(result.data);
|
||||
|
||||
// Stop polling if no more pending
|
||||
if (result.data.counts.pending === 0) {
|
||||
stopWebhookQueuePolling();
|
||||
}
|
||||
}
|
||||
}, 10000); // Check every 10 seconds
|
||||
}
|
||||
|
||||
// Stop polling
|
||||
function stopWebhookQueuePolling() {
|
||||
if (webhookQueueInterval) {
|
||||
clearInterval(webhookQueueInterval);
|
||||
webhookQueueInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Render webhook queue status
|
||||
function renderWebhookQueueStatus(data) {
|
||||
const container = document.getElementById('webhookQueueContainer');
|
||||
|
||||
Reference in New Issue
Block a user