Skip to content

bot-gateway downstream client has no circuit breaker #33

Description

@Hqzdev

Problem

bot-gateway sends every user action directly to downstream services with only a per-request timeout. There is no circuit breaker state, cooldown, fallback counter, or fast failure when booking/payment services are already unhealthy.

Evidence

  • apps/bot/services/bot-gateway/src/services-client.ts:283 centralizes downstream requests.
  • apps/bot/services/bot-gateway/src/services-client.ts:290 calls fetch for every request.
  • apps/bot/services/bot-gateway/src/services-client.ts:294 has a timeout, but there is no breaker around repeated failures.
  • apps/bot/services/bot-gateway/src/services-client.ts:298 converts non-2xx responses to ServiceHttpError, but does not update breaker state or return a controlled fallback.

Impact

When booking-service or payment-service is down, every Telegram user action waits up to the timeout and keeps adding load to the failed dependency. This can amplify incidents and make the bot feel frozen.

Expected Fix

Add circuit breakers around downstream targets, starting with booking and payment:

  • track failures per target service;
  • open after a threshold and return a fast fallback response;
  • use half-open probes after cooldown;
  • emit logs/metrics such as circuit.open, circuit.fallback, and current breaker state;
  • cover open and half-open behavior with unit tests.

Activity

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

Metadata

Metadata

Assignees

Labels

botBot gateway or bot runtimeenhancementNew feature or requestresilienceResilience patterns and fallback behavior

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions