-
Notifications
You must be signed in to change notification settings - Fork 20
feat: configurable webhook timeout #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/oidc-main-sync
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,16 @@ | |
|
|
||
| import fetch from 'node-fetch' | ||
|
|
||
| const DEFAULT_TIMEOUT = 5000; | ||
|
|
||
| export const sendWebhookEvent = async ( | ||
| webhookUrl: string, | ||
| body: Record<string, unknown>, | ||
| logger: Logger, | ||
| timeoutMs = 5000, | ||
| timeoutMs: number = parseInt(process.env.WEBHOOK_TIMEOUT_MS || '', 10) || DEFAULT_TIMEOUT, | ||
|
Check warning on line 11 in src/events/WebhookEvent.ts
|
||
| ): Promise<void> => { | ||
|
|
||
| console.log(`Sending webhook event to ${webhookUrl} with timeout of ${timeoutMs}ms`) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Verify which logger levels are used in the repo so replacement matches existing conventions.
rg -n --type=ts -C2 '\blogger\.(trace|debug|info|warn|error)\('
# Inspect local logger-related typings/usages to confirm available methods.
rg -n --type=ts -C2 'type Logger|interface Logger|from .+Logger'Repository: credebl/agent-controller Length of output: 12863 🏁 Script executed: cat -n src/events/WebhookEvent.tsRepository: credebl/agent-controller Length of output: 1597 Replace Line 14 uses direct console logging which triggers Replace with:logger.info(`Sending webhook event to ${webhookUrl} with timeout of ${timeoutMs}ms`)🧰 Tools🪛 ESLint[error] 14-14: Unexpected console statement. (no-console) 🤖 Prompt for AI Agents |
||
| // Abort the webhook send events if the request hangs-in for >5 secs | ||
| // This can avoid failure of services due to bad webhook listners | ||
| const controller = new AbortController() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate resolved timeout before using it.
Line 11 currently trusts parsed env values too much; a negative
WEBHOOK_TIMEOUT_MSwill cause near-immediate aborts. Since several event modules call this function without an explicit timeout, this can break webhook delivery globally.💡 Proposed fix
Also applies to: 18-18
🧰 Tools
🪛 ESLint
[error] 5-5: Delete
;(prettier/prettier)
🪛 GitHub Check: SonarCloud Code Analysis
[warning] 11-11: Prefer
Number.parseIntoverparseInt.See more on https://sonarcloud.io/project/issues?id=credebl_afj-controller&issues=AZ3PACJiNgPe1EPLZpl-&open=AZ3PACJiNgPe1EPLZpl-&pullRequest=365
🤖 Prompt for AI Agents