{"record":{"id":"17fa0d5694a68a0b","repo":"gatsbyjs/gatsby","slug":"neither-cache-or-getcache-was-passed-getcache-17fa0d","errorCode":null,"errorMessage":"Neither \"cache\" or \"getCache\" was passed. getCache must be function that return Gatsby cache, \"cache\" must be the Gatsby cache, was ${typeof cache}","messagePattern":"Neither \"cache\" or \"getCache\" was passed\\. getCache must be function that return Gatsby cache, \"cache\" must be the Gatsby cache, was (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby-source-filesystem/src/create-remote-file-node.js","lineNumber":127,"sourceCode":"  name = null,\n}) {\n  // validation of the input\n  // without this it's notoriously easy to pass in the wrong `createNodeId`\n  // see gatsbyjs/gatsby#6643\n  if (typeof createNodeId !== `function`) {\n    throw new Error(\n      `createNodeId must be a function, was ${typeof createNodeId}`\n    )\n  }\n  if (typeof createNode !== `function`) {\n    throw new Error(`createNode must be a function, was ${typeof createNode}`)\n  }\n  if (typeof getCache === `function`) {\n    // use cache of this plugin and not cache of function caller\n    cache = getCache(`gatsby-source-filesystem`)\n  }\n  if (typeof cache !== `object`) {\n    throw new Error(\n      `Neither \"cache\" or \"getCache\" was passed. getCache must be function that return Gatsby cache, \"cache\" must be the Gatsby cache, was ${typeof cache}`\n    )\n  }\n\n  // Check if we already requested node for this remote file\n  // and return stored promise if we did.\n  if (processingCache[url]) {\n    return processingCache[url]\n  }\n\n  if (!url || isWebUri(url) === undefined) {\n    throw new Error(\n      `url passed to createRemoteFileNode is either missing or not a proper web uri: ${url}`\n    )\n  }\n\n  const fileDownloadPromise = processRemoteNode({\n    url,","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L109-L145","documentation":"createRemoteFileNode needs a cache to store download metadata, dedupe URLs (processingCache is persisted across builds), and track content digests. After trying `getCache('gatsby-source-filesystem')`, if `cache` is still not an object this error fires. The message names both accepted inputs so callers know the two ways to satisfy the requirement.","triggerScenarios":"Calling createRemoteFileNode without cache or getCache; passing cache: undefined after a refactor; passing a plain object that is not the Gatsby cache instance; using the API inside onPreInit or another lifecycle that lacks cache.","commonSituations":"Migrating to a newer gatsby-source-filesystem where cache became required; copying example code that omitted cache; building a transformer plugin that calls createRemoteFileNode without forwarding helpers; CI environments where the cache dir is unwritable causing cache resolution to return non-object.","solutions":["Forward cache from helpers: exports.sourceNodes = async ({ cache, actions, createNodeId }) => { await createRemoteFileNode({ url, cache, createNode: actions.createNode, createNodeId }) }.","If cache is not directly available, pass getCache so the plugin resolves its own namespaced cache.","Confirm the cache object is the Gatsby cache (has get/set/del) and not an unrelated object.","Avoid calling createRemoteFileNode outside of a lifecycle that provides cache."],"exampleFix":"// before\nawait createRemoteFileNode({\n  url,\n  createNode,\n  createNodeId,\n})\n\n// after\nawait createRemoteFileNode({\n  url,\n  cache,\n  createNode,\n  createNodeId,\n})","handlingStrategy":"validation","validationCode":"if (!(typeof cache === 'object' && cache) && typeof getCache !== 'function') {\n  throw new Error('createRemoteFileNode needs cache or getCache from helpers')\n}","typeGuard":"const isCache = (v) => v && typeof v === 'object' && typeof v.get === 'function'","tryCatchPattern":"try { await createRemoteFileNode(opts) } catch (e) { if (/Neither \"cache\" or \"getCache\"/.test(e.message)) { reporter.panic('Cache not forwarded to createRemoteFileNode') } throw e }","preventionTips":["Forward cache from helpers in every sourceNodes call site","Provide a project helper that bundles createRemoteFileNode with the standard helpers pre-bound","Test the call with the real cache object before relying on it in production builds"],"tags":["gatsby","validation","config","cache"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}