Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Catch provider setup errors instead of crashing the server at boot

Chiusa Adatta ai principianti
#175 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
83/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend

Direzione di ricerca

Inizia da packages/server/src/handler.ts, nella creazione del provider intorno alla riga 18 e nell'await in handleChat intorno alla riga 33, poi leggi i test esistenti dell'handler in packages/server/tests/handler.test.ts, che simulano createProvider. Verifica come vengono restituiti gli errori nella generazione delle risposte e come sono coperti la validazione e il rate limiting. Il lavoro è concluso quando il rifiuto durante la configurazione viene gestito e registrato una sola volta, le richieste restituiscono { error: 'provider_error' } e i test includono un changeset di tipo patch per @chatcops/server.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug good first issue hacktoberfest server

createChatHandler starts creating the provider right away and only awaits it inside the first request (packages/server/src/handler.ts, line 18 and line 33). If that promise rejects, for example with an unknown provider.type or a provider SDK that throws on a missing key, nothing handles the rejection. Node treats an unhandled rejection as fatal by default, so the whole server process exits at startup. After that, if the process survives, every request rethrows at line 33, outside the try that starts further down, and the visitor gets a bare internal_error.

What to do

  • Handle the rejection where the promise is created, and log it once with the [chatcops] prefix, for example [chatcops] Provider setup failed: <message>. Don't log the API key or the config object.
  • In handleChat, await the provider inside a try and yield { error: 'provider_error' } when setup failed, the same error the visitor already sees for a failed reply.
  • Keep request validation and rate limiting working as they do today.

Acceptance criteria

  • A handler created with a provider whose setup rejects doesn't cause an unhandled rejection (a test can listen for unhandledRejection, or check that the rejection is handled)
  • Requests to that handler yield { error: 'provider_error' } and the setup error is logged once, not once per request
  • Tests in packages/server/tests/handler.test.ts (it already mocks createProvider)
  • Changeset for @chatcops/server (patch)
  • pnpm -r build, pnpm test and pnpm -r typecheck pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #<this issue number>. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.

Lingua principale
TypeScript
Stelle
13
Fork
7
Merge medio
3h 41m
PR unite (30g)
155

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codercops/chatcops

Tutte le issue di codercops/chatcops

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.