Skip to content

Support ticketing — JIRA HTTP resilience

Support ticketing — JIRA HTTP resilience (TIX-16)

Reference for engineers and operators maintaining outbound support-ticket integrations.

Purpose

Outbound support flows call JIRA Cloud REST (issue create, attachments). Both can return transient 429 (rate limit) or 5xx errors. Serverless handlers retry those responses with backoff so a brief outage does not fail ticket sync on the first attempt.

L1 email (TIX-9) uses SMTP (api/_lib/smtpEmail.ts), not Resend — same SMTP_* vars as KPI alerts and storefront mail.

What is retried

ClientFileCalls
JIRA RESTapi/_lib/jira.tsjiraRequest (JSON API), attachFileToJiraIssue (multipart)

Shared helper: api/_lib/httpRetry.tsfetchWithRetry.

Retry policy

SettingValue
Max attempts4 (1 initial + 3 retries)
Retry whenHTTP 429 or 5xx
No retry4xx other than 429 (e.g. 401, 404) — fail immediately
BackoffExponential from 500 ms, cap 8 s, small jitter
Retry-AfterHonoured when JIRA sends the header (seconds or HTTP-date)

After all attempts are exhausted, the last response is returned. Callers (JiraRequestError) surface a clean failure to logs and support_tickets.jira_sync_error — no infinite loops.

L1 email (SMTP, not retried via httpRetry)

EnvPurpose
SMTP_SERVER, SMTP_PORT, SMTP_LOGIN, SMTP_PASSWORDGmail/relay auth
SMTP_FROM_EMAIL, SMTP_FROM_NAMEFrom header
SUPPORT_L1_EMAIL or SMTP_LOGINL1 inbox (to address)

sendSmtpEmail tries configured port then 587/465 fallback on network errors.

What is not retried

  • Inbound JIRA webhooks (api/support/jira-webhook.ts) — JIRA redelivers on its side; idempotent inbox handles duplicates.
  • pg_net queue retries for /api/support/jira-sync and /api/support/l1-notify remain separate (DB-level re-queue on handler failure).

Verify locally

Terminal window
npm run test -- tests/api/httpRetry.test.ts tests/api/jiraClient.test.ts

Operations

SymptomLikely causeAction
support_tickets.jira_sync_attempts high / sync failingSustained JIRA outage or bad credentialsCheck Vercel logs for JiraRequestError; verify jira_* / JIRA_* env
L1 email missing but ticket createdSMTP misconfiguration or relay blockedCheck SMTP_* env; Vercel may block outbound SMTP on some plans
Slow sync after rate limitExpected — backoff up to ~8 s per attemptNormal; reduce burst if Atlassian throttles often
  • PRD: docs/specs/ticketing-jira-prd.md — §E8, §Risks & mitigations
  • Webhook setup: docs/specs/support-jira-webhook-setup.md
  • JIRA client: api/_lib/jira.ts