Difficulty: Advanced
Type: feature
Background
The "Local dashboard integration gateway" uses server-side Next.js route handlers to reach @guildpass/integration-client (an optional, private package) without exposing INTEGRATION_API_KEY to the browser, returning safe 503s if the package or key is missing, per the README.
Problem
Beyond the missing-package/key case, the gateway routes (/api/integration/membership, /api/integration/verify) have no described resilience against a slow or intermittently failing upstream integration client — a hanging or flaky call could tie up server resources or produce inconsistent user-facing errors.
Expected outcome
Both gateway routes apply a request timeout, a small number of retries with backoff for transient failures, and a simple circuit breaker that short-circuits to a fast 503 once repeated failures are detected, recovering automatically after a cooldown.
Suggested implementation
- Add a shared server-side utility (e.g.,
lib/integration/resilientCall.ts) implementing timeout + retry-with-backoff + a basic circuit breaker (open/half-open/closed states) usable by both route handlers.
- Wire both
/api/integration/membership and /api/integration/verify through this utility.
- Ensure the existing "missing package/key → safe 503" behavior is preserved and distinguishable (e.g., via a response field or log message) from a circuit-breaker-triggered 503.
- Add tests simulating transient failures (retry succeeds), persistent failures (circuit opens), and recovery (circuit half-opens and closes again).
Acceptance criteria
Likely affected files/directories
app/api/integration/ (route handlers)
lib/integration/ (new resilience utility)
Difficulty: Advanced
Type: feature
Background
The "Local dashboard integration gateway" uses server-side Next.js route handlers to reach
@guildpass/integration-client(an optional, private package) without exposingINTEGRATION_API_KEYto the browser, returning safe503s if the package or key is missing, per the README.Problem
Beyond the missing-package/key case, the gateway routes (
/api/integration/membership,/api/integration/verify) have no described resilience against a slow or intermittently failing upstream integration client — a hanging or flaky call could tie up server resources or produce inconsistent user-facing errors.Expected outcome
Both gateway routes apply a request timeout, a small number of retries with backoff for transient failures, and a simple circuit breaker that short-circuits to a fast
503once repeated failures are detected, recovering automatically after a cooldown.Suggested implementation
lib/integration/resilientCall.ts) implementing timeout + retry-with-backoff + a basic circuit breaker (open/half-open/closed states) usable by both route handlers./api/integration/membershipand/api/integration/verifythrough this utility.Acceptance criteria
Likely affected files/directories
app/api/integration/(route handlers)lib/integration/(new resilience utility)