{"record":{"id":"83f3243bc4e73575","repo":"JuliusBrussee/caveman","slug":"recordoutcome-no-global-fetch-pass-client-fetch","errorCode":null,"errorMessage":"recordOutcome: no global fetch; pass client.fetch","messagePattern":"recordOutcome: no global fetch; pass client\\.fetch","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mastra/src/index.ts","lineNumber":723,"sourceCode":"  );\n\n  const text = await response.text();\n  const ok = response.ok ?? (response.status >= 200 && response.status < 300);\n  if (!ok) throw new CavemanOutcomeError(response.status, text);\n\n  let parsed: { data?: unknown; created?: unknown };\n  try {\n    parsed = JSON.parse(text) as { data?: unknown; created?: unknown };\n  } catch {\n    throw new CavemanOutcomeError(response.status, text);\n  }\n  return { status: response.status, created: parsed.created === true, record: parsed.data ?? null };\n}\n\nfunction globalFetch(url: string, init: RequestInitLike): Promise<ResponseLike> {\n  const fetchImpl = (globalThis as { fetch?: (u: string, i: unknown) => Promise<ResponseLike> }).fetch;\n  if (typeof fetchImpl !== \"function\") {\n    throw new Error(\"recordOutcome: no global fetch; pass client.fetch\");\n  }\n  return fetchImpl(url, init);\n}\n\n/**\n * JSON with object keys sorted at every level. Throws on anything that is not a\n * plain object, array, string, finite number, boolean, or null — a Date, a Map,\n * or a class instance would serialize into something the caller did not mean,\n * and the record's digest is its identity.\n */\nexport function stableStringify(value: unknown, path = \"value\"): string {\n  if (value === null) return \"null\";\n  switch (typeof value) {\n    case \"string\":\n      return JSON.stringify(value);\n    case \"boolean\":\n      return value ? \"true\" : \"false\";\n    case \"number\":","sourceCodeStart":705,"sourceCodeEnd":741,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/mastra/src/index.ts#L705-L741","documentation":"Environment guard in recordOutcome's globalFetch helper: neither a custom fetch was supplied via client.fetch nor a global fetch (globalThis.fetch) exists, so the HTTP call to the control API cannot be made at all.","triggerScenarios":"Thrown at packages/mastra/src/index.ts:723 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a fetch implementation in the client options: recordOutcome(..., { fetch: myFetch })","Run on Node 18+ or a runtime where globalThis.fetch is defined","Polyfill globalThis.fetch (e.g. undici or node-fetch) before calling recordOutcome"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}