(url: string, payload: Record<string, unknown>, secret?: string)
| 10 | } |
| 11 | |
| 12 | export async function dispatchCallback(url: string, payload: Record<string, unknown>, secret?: string): Promise<void> { |
| 13 | const body = JSON.stringify(payload) |
| 14 | const headers: Record<string, string> = { 'Content-Type': 'application/json' } |
| 15 | if (secret) headers['X-Flowise-Signature'] = sign(body, secret) |
| 16 | |
| 17 | for (let attempt = 0; attempt < RETRY_DELAYS.length; attempt++) { |
| 18 | if (RETRY_DELAYS[attempt] > 0) { |
| 19 | await new Promise((r) => setTimeout(r, RETRY_DELAYS[attempt])) |
| 20 | } |
| 21 | try { |
| 22 | await secureAxiosRequest({ method: 'POST', url, data: body, headers, timeout: 10000 }) |
| 23 | return |
| 24 | } catch (err: any) { |
| 25 | if (attempt === RETRY_DELAYS.length - 1) { |
| 26 | logger.error( |
| 27 | `[callbackDispatcher] Failed to deliver callback to ${url} after ${RETRY_DELAYS.length} attempts: ${err.message}` |
| 28 | ) |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |
no test coverage detected