fix(ai-connectors): deduplicate outage bridge DMs per conversation with a cooldown
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- postgresql, redis, typescript
Direzione di ricerca
Start with apps/api/src/ai-connectors/ai-connectors.service.ts, especially AiConnectorsService and dispatchCompletion, then read apps/api/src/redis/redis.service.ts and the Message model in packages/prisma/schema.prisma. Check how Redis disconnection and existing constructor tests are handled. Done means both outage notifications are suppressed for 15 minutes per conversation, with a database fallback when Redis is unavailable.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem Description
In apps/api/src/ai-connectors/ai-connectors.service.ts (dispatchCompletion, lines 546-617), when all AI providers fail and conversationId is present, it unconditionally enqueues a SEND_DM BackgroundJob with bridgeMsg and creates an INTERNAL_NOTE ([AI Outage Alert]) on the conversation with no per-conversation cooldown.
If a customer sends multiple messages while AI providers are down, they receive duplicate bridgeMsg DMs and the conversation gets spammed with duplicate internal notes.
Expected Behavior
- During an AI outage, both
bridgeMsgand the[AI Outage Alert]INTERNAL_NOTEare emitted at most once per conversation within a cooldown window (e.g., 15 minutes). - Works reliably both locally (even without Redis) and in production across multiple API replicas, without breaking existing unit tests.
Where to Look
apps/api/src/ai-connectors/ai-connectors.service.ts(AiConnectorsServiceconstructor line 33,dispatchCompletionlines 546-617)apps/api/src/redis/redis.service.ts(reserveWebhookEventlines 167-197)packages/prisma/schema.prisma(Messagemodel, usessentAt)
Solution / Implementation Guide
- Inject
@Optional() private readonly redisService?: RedisServiceintoAiConnectorsService(RedisModuleis@Global(), and@Optional()preserves existing unit test constructors). - Add a cooldown helper in
RedisService(e.g.,acquireCooldown(key: string, ttlSeconds: number): Promise<boolean>usingSET key '1' EX ttlSeconds NX, returningtrueif acquired or falling back safely if Redis is disconnected). - Gate both
bridgeMsgandINTERNAL_NOTEbehind the 15-minute cooldown indispatchCompletion:- If
this.redisServiceis available: callawait this.redisService.acquireCooldown(\ai:outage_bridge:${conversationId}`, 900)`. - DB fallback (if Redis is unavailable locally): query
prisma.message.findFirstwithwhere: { conversationId, messageType: 'INTERNAL_NOTE', content: { contains: 'AI Outage Alert' }, sentAt: { gte: new Date(Date.now() - 15 * 60 * 1000) } }(note:MessageusessentAt, notcreatedAt). - If the cooldown is active (already sent within 15 minutes), skip both enqueuing the
SEND_DMbridgeMsgjob and creating theINTERNAL_NOTE.
- If
- Lingua principale
- TypeScript
- Stelle
- 2
- Fork
- 1
- Merge medio
- 6m
- PR unite (30g)
- 27
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sumamakhan761/tryinstance
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sumamakhan761/tryinstance#65 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
sumamakhan761/tryinstance#64 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
sumamakhan761/tryinstance#63 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sumamakhan761/tryinstance#62 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sumamakhan761/tryinstance#60 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di sumamakhan761/tryinstance
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
makecindy/cindy#15342 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
kwitsch/claude-code-plugin-tooling#219 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
no-repo-link tool-submission
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100