Catch provider setup errors instead of crashing the server at boot
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 83/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- node.js, typescript
- 領域
- backend
研究方向
從packages/server/src/handler.ts中第18行左右的provider建立處和第33行左右handleChat中的await處開始,接著閱讀packages/server/tests/handler.test.ts中模擬createProvider的既有handler測試。檢查回覆失敗如何傳回,以及validation和rate limiting如何涵蓋。完成條件是:setup遭拒時會得到處理並且只記錄一次;請求傳回{ error: 'provider_error' };測試包含@chatcops/server的patch changeset。
由索引模型根據 Issue 內容生成。
描述
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 atryand 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 mockscreateProvider) - Changeset for
@chatcops/server(patch) -
pnpm -r build,pnpm testandpnpm -r typecheckpass
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.
- 主要語言
- TypeScript
- 星號
- 13
- 分支
- 7
- 平均合併
- 3 小時 41 分鐘
- 30 天內合併 PR
- 155
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
codercops/chatcops 的其他 Issue
-
Document the pre-chat form可能已有人在做 @masyarakatai 於 5 天前認領。 未關閉documentation good first issue hacktoberfest widget
難度 2/5 1-3 小時 新手友好度 88/100
codercops/chatcops#70 · 5 則留言 ·
維護者通常 1 天內回覆
-
docs: update the providers page for openai-compatible, registerProvider and provider imports可能已有人在做 @prakashNalla 今天認領。 未關閉documentation good first issue hacktoberfest website
難度 3/5 1-2 天 新手友好度 76/100
codercops/chatcops#291 · 1 則留言 ·
維護者通常 1 天內回覆
-
docs: add a protocol reference page for custom clients可能已有人在做 @kachamsiddarth 今天認領。 未關閉documentation good first issue hacktoberfest website
codercops/chatcops#286 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter)可能已有人在做 @bhushan4work 今天認領。 未關閉enhancement hacktoberfest help wanted server
難度 5/5 一週以上 新手友好度 25/100
codercops/chatcops#249 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Create @chatcops/store-sqlite, a store for single-server setups可能已有人在做 @srikar-naidu 今天認領。 未關閉enhancement hacktoberfest help wanted server
難度 5/5 一週以上 新手友好度 35/100
codercops/chatcops#247 · 3 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
查看 codercops/chatcops 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 72/100
zts212653/clowder-ai#1678 ·
維護者通常 1 天內回覆
-
good first issue
難度 2/5 1-3 小時 新手友好度 64/100
Progressive-Victory/the-website#680 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 68/100