Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Catch provider setup errors instead of crashing the server at boot

已關閉 適合新手
#175 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 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 內容生成。

描述

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.

主要語言
TypeScript
星號
13
分支
7
平均合併
3 小時 41 分鐘
30 天內合併 PR
155

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

codercops/chatcops 的其他 Issue

查看 codercops/chatcops 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。