chroma-core/chroma · error · Error
Error calling Cloudflare Workers AI API: ${error}
Error message
Error calling Cloudflare Workers AI API: ${error} What it means
The else-branch of the same wrapper in CloudflareWorkersAIEmbeddingFunction.generate: when the caught value is NOT an instance of Error (e.g. a thrown string, number, or object - possible from exotic fetch implementations, monkey-patched fetch, or environment quirks like some DOMException variants), it is stringified into the message 'Error calling Cloudflare Workers AI API: ${error}'. Rare compared to the Error branch; same debugging approach applies.
Source
Thrown at clients/js/packages/chromadb-core/src/embeddings/CloudflareWorkersAIEmbeddingFunction.ts:89
method: "POST",
headers: this.headers,
body: JSON.stringify(payload),
});
const resp = await response.json();
if (!resp.result || !resp.result.data) {
throw new Error(resp.detail || "Unknown error");
}
return resp.result.data;
} catch (error) {
if (error instanceof Error) {
throw new Error(
`Error calling Cloudflare Workers AI API: ${error.message}`,
);
} else {
throw new Error(`Error calling Cloudflare Workers AI API: ${error}`);
}
}
}
buildFromConfig(config: StoredConfig): CloudflareWorkersAIEmbeddingFunction {
return new CloudflareWorkersAIEmbeddingFunction({
model_name: config.model_name,
account_id: config.account_id,
api_key_env_var: config.api_key_env_var,
gateway_id: config.gateway_id ?? undefined,
});
}
getConfig(): StoredConfig {
return {
model_name: this.model_name,
account_id: this.account_id,
api_key_env_var: this.api_key_env_var,View on GitHub (pinned to aecdd12c8a)
Solutions
- Inspect the stringified value in the message suffix to identify what was actually thrown.
- If you control the fetch polyfill/mock, make it reject with real Error objects.
- Treat it like the Error-branch wrapper: network/API debugging plus retry logic where appropriate.
Example fix
// before (test mock)
vi.stubGlobal('fetch', vi.fn(async () => { throw 'boom'; }));
// after
vi.stubGlobal('fetch', vi.fn(async () => { throw new Error('boom'); })); Defensive patterns
Strategy: try-catch
Try / catch
try {
await ef.generate(texts);
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
if (msg.startsWith('Error calling Cloudflare Workers AI API:')) {
// non-Error rejection: inspect the stringified suffix to find the real cause
// if running in tests, fix fetch mocks to reject with real Error objects
}
throw e;
} Prevention
- Make custom fetch implementations and test mocks always reject with Error instances.
- In edge runtimes, smoke-test the embedding path in the actual runtime, not just Node.
- Log the full wrapped message; the suffix identifies the thrown non-Error value.
When it happens
Trigger: Custom/edge fetch implementations (workers, undici forks) rejecting with non-Error values; test doubles that throw plain objects; older runtimes where a rejection reason loses its Error prototype.
Common situations: Running the client inside non-Node runtimes (Cloudflare Workers themselves, Deno compatibility layers); unit tests with vi.fn() mocks rejecting with strings.
Related errors
- Error calling Cloudflare Workers AI API: ${error.message}
- resp.detail || "Unknown error"
- Error calling Jina AI API: ${error}
- Cloudflare API key is required. Please provide it in the con
- Error calling Jina AI API: ${error.message}
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/fd24c3849328f921.
Report an issue: GitHub.