perf(config/findings): getOpenCodeHttpsAgent 改模組單例、normalizeText 加 memoization 快取
另含 comments.js bySeverity 改用預建 LEVEL_RANK Map(隨 fix commit 一併提交)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
402630fa69
commit
998b5ca5ac
+5
-3
@@ -16,12 +16,14 @@ export const EXCLUSIONS_PATH = '.gitea/ai-review/exclusions.json';
|
||||
* 建立一個停用 TLS 憑證驗證(`rejectUnauthorized: false`)的 HTTPS Agent,
|
||||
* 供連接使用自簽或無效憑證的 OpenCode 服務時使用。
|
||||
*
|
||||
* @remarks 每次呼叫都會回傳全新的 Agent 實例(不快取),建議呼叫端重用以共用連線池。
|
||||
* @remarks 首次呼叫時建立,之後快取為模組層級單例(singleton)重複使用,
|
||||
* 避免每次都新建 Agent 與連線池、浪費 TCP 三次握手。
|
||||
* 停用憑證驗證有中間人攻擊風險,僅限受信任的內部環境使用。
|
||||
* @returns {import('https').Agent} 已關閉憑證驗證的 HTTPS Agent 實例。
|
||||
* @returns {import('https').Agent} 已關閉憑證驗證的 HTTPS Agent 單例。
|
||||
*/
|
||||
let _openCodeHttpsAgent = null;
|
||||
export function getOpenCodeHttpsAgent() {
|
||||
return new https.Agent({ rejectUnauthorized: false });
|
||||
return (_openCodeHttpsAgent ??= new https.Agent({ rejectUnauthorized: false }));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user