Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(open-sse): serialize xxhash startup in cch hashing

diegosouzapwcd56ea7040be
diff --git a/open-sse/services/claudeCodeCCH.ts b/open-sse/services/claudeCodeCCH.ts
index 9c4b4df7c8..567de2cc15 100644
--- a/open-sse/services/claudeCodeCCH.ts
+++ b/open-sse/services/claudeCodeCCH.ts
@@ -17,12 +17,18 @@ import xxhashInit from "xxhash-wasm";
const CCH_SEED = 0x6e52736ac806831en;
const CCH_PATTERN = /\bcch=([0-9a-f]{5});/;
+let xxhashPromise: Promise<void> | null = null;
let xxhash64Fn: ((input: Uint8Array, seed: bigint) => bigint) | null = null;
async function ensureXxhash() {
if (xxhash64Fn) return;
- const hasher = await xxhashInit();
- xxhash64Fn = hasher.h64Raw;
+ if (!xxhashPromise) {
+ xxhashPromise = (async () => {
+ const hasher = await xxhashInit();
+ xxhash64Fn = hasher.h64Raw;
+ })();
+ }
+ return xxhashPromise;
}
export async function computeCCH(bodyBytes: Uint8Array): Promise<string> {