Skip to content

feat: graceful degradation strategy for service mode failures #11

Description

@mdesoto

Context

When service mode launches, verify() will make HTTP calls to the BurnerGuard API. Network calls fail — timeouts, 5xx errors, rate limiting, DNS issues. The library needs a clear, configurable strategy for what happens when the API is unreachable.

This is a must-have before service mode goes live.

Proposed behavior

Configuration

const guard = await BurnerGuard.create({
    apiKey: 'bg_live_...',
    fallback: 'static',       // 'static' | 'throw' | 'allow'
    serviceTimeout: 5000       // ms before falling back (default: 5000)
});

Fallback strategies

Strategy Behavior Use case
'static' (default) Fall back to local blocklist check Best of both worlds — never blocks legitimate users, still catches known disposable domains
'throw' Throw an error Strict environments where you'd rather fail the request than risk letting a bad email through
'allow' Return { isMatch: false } Permissive environments where you'd rather let a potentially bad email through than block a legitimate user

Result indication

When a fallback occurs, the result should indicate it:

{
    isMatch: true,
    matchedOn: ['blocklist'],
    isAllowlisted: false,
    degraded: true,             // indicates this was a fallback, not a full service check
    degradedReason: 'timeout'   // 'timeout' | 'serviceError' | 'rateLimited'
}

Retry behavior

  • No automatic retries in the library — the consumer controls retry logic
  • But expose enough info (degradedReason) for the consumer to make retry decisions

Open questions

  • Should degraded and degradedReason be on VerifyResult (always present) or only on EnrichedVerifyResult?
  • Should there be an onDegradation callback for logging/alerting?
  • Should the fallback strategy be overridable per-call via VerifyOptions?

Acceptance criteria

  • fallback option in BurnerGuardOptions with 'static', 'throw', and 'allow' strategies
  • serviceTimeout option
  • degraded and degradedReason fields in verify result
  • Correct behavior for each fallback strategy on timeout, 5xx, rate limit
  • Tests covering: each fallback strategy, timeout handling, degraded result fields
  • README section explaining degradation strategies and when to use each

Priority: 🟡 Medium — must-have before service mode launches

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions