{"record":{"id":"5a652da21de516b1","repo":"DIYgod/RSSHub","slug":"create64-is-not-supported-in-worker-shim","errorCode":null,"errorMessage":"create64 is not supported in Worker shim","messagePattern":"create64 is not supported in Worker shim","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/shims/xxhash-wasm.ts","lineNumber":75,"sourceCode":"        // In practice, only h64ToString is used and it's called with await xxhash()\n        h64: (_input: string, _seed?: bigint): bigint => {\n            throw new Error('h64 is not supported in Worker shim, use h64ToString instead');\n        },\n        h64ToString: (input: string, _seed?: bigint): string => {\n            // This needs to be sync to match the API, but we use a simple hash\n            // The actual usage in cache.ts awaits xxhash() first, so this works\n            let hash = 0n;\n            const data = encoder.encode(input);\n            for (const byte of data) {\n                hash = ((hash << 5n) - hash + BigInt(byte)) & 0xff_ff_ff_ff_ff_ff_ff_ffn;\n            }\n            return hash.toString(16).padStart(16, '0');\n        },\n        h64Raw: (_inputBuffer: Uint8Array, _seed?: bigint): bigint => {\n            throw new Error('h64Raw is not supported in Worker shim');\n        },\n        create64: (_seed?: bigint): XXHash<bigint> => {\n            throw new Error('create64 is not supported in Worker shim');\n        },\n    };\n}\n\nexport default xxhash;\n","sourceCodeStart":57,"sourceCodeEnd":81,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/shims/xxhash-wasm.ts#L57-L81","documentation":"Thrown by the Workers shim for xxhash-wasm when create64 is called. create64 returns a streaming XXHash<bigint> object (update/digest) that the shim cannot provide without WASM, so it aborts. The shim intentionally supports only the stateless h64ToString fallback used by cache.ts.","triggerScenarios":"Calling xxhash().create64(seed) and then .update()/.digest() in code that ends up in the Worker bundle. Any new code that streams chunks through a 64-bit hasher will hit this in the Worker environment.","commonSituations":"Introducing a code path that incrementally hashes large payloads with create64; pulling in a shared utility that picks create64 over h64ToString; cache key generation that was refactored to use the streaming API.","solutions":["Use h64ToString on the fully concatenated input instead of create64().update().digest().","Move the streaming-hash logic out of the Worker bundle into the Node-only entry.","If only a 32-bit stream is needed, use create32 which IS implemented in the shim (lib/shims/xxhash-wasm.ts:37)."],"exampleFix":"// before\nconst h = (await xxhash()).create64(seed);\nfor (const c of chunks) h.update(c);\nconst digest = h.digest();\n// after\nconst h = (await xxhash()).create32(seed);\nfor (const c of chunks) h.update(c);\nconst digest = h.digest();","handlingStrategy":"type-guard","validationCode":"function canStream64(api: any): boolean {\n  try { const h = api.create64(); return typeof h?.update === 'function'; } catch { return false; }\n}","typeGuard":"const isCreate64Usable = (api: XXHashAPI): boolean => {\n  try { api.create64(); return true; } catch { return false; }\n};","tryCatchPattern":"try {\n  const h = (await xxhash()).create64(seed);\n  chunks.forEach((c) => h.update(c));\n  return h.digest();\n} catch (e) {\n  if (/not supported in Worker shim/.test((e as Error).message)) {\n    return (await xxhash()).h64ToString(chunks.join(''), seed);\n  }\n  throw e;\n}","preventionTips":["Avoid the streaming 64-bit API in code that runs in the Worker bundle - prefer stateless h64ToString.","For incremental hashing under Workers, use create32 which the shim supports.","Document the Worker-incompatible methods at the top of any module that uses xxhash."],"tags":["cloudflare-workers","xxhash","shim","wasm","streaming"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}