{"record":{"id":"7d988a592e0f478a","repo":"parcel-bundler/parcel","slug":"config-result-is-not-hashable-because-it-contains","errorCode":null,"errorMessage":"Config result is not hashable because it contains non-serializable objects. Please use config.setCacheKey to set the hash manually.","messagePattern":"Config result is not hashable because it contains non-serializable objects\\. Please use config\\.setCacheKey to set the hash manually\\.","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/requests/ConfigRequest.js","lineNumber":245,"sourceCode":"\n  // If there is no result hash set by the transformer, default to hashing the included\n  // files if any, otherwise try to hash the config result itself.\n  if (config.cacheKey == null) {\n    if (config.invalidateOnFileChange.size > 0) {\n      hash.writeString(\n        await getInvalidationHash(\n          [...config.invalidateOnFileChange].map(filePath => ({\n            type: 'file',\n            filePath,\n          })),\n          options,\n        ),\n      );\n    } else if (config.result != null) {\n      try {\n        hash.writeBuffer(serializeRaw(config.result));\n      } catch (err) {\n        throw new ThrowableDiagnostic({\n          diagnostic: {\n            message:\n              'Config result is not hashable because it contains non-serializable objects. Please use config.setCacheKey to set the hash manually.',\n            origin: pluginName,\n          },\n        });\n      }\n    }\n  } else {\n    hash.writeString(config.cacheKey ?? '');\n  }\n\n  return hash.finish();\n}\n\nexport function getConfigRequests(\n  configs: Array<Config>,\n): Array<ConfigRequest> {","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/requests/ConfigRequest.js#L227-L263","documentation":"To cache a config result, Parcel hashes it. When `config.cacheKey` is null and `config.result` is non-null, it tries `serializeRaw(config.result)`. If the result contains non-serializable values (functions, class instances, symbols, circular structures), serialization throws and Parcel wraps it in this diagnostic telling you to set a manual cache key.","triggerScenarios":"A config plugin returns a result object that contains functions, class instances, or other non-plain-serializable data, and does not call `config.setCacheKey()`.","commonSituations":"Config loaders that return compiled regexes, function factories, or third-party class instances; configs that capture closures.","solutions":["Call `config.setCacheKey(manualHash)` with a stable string derived from the config inputs.","Return only JSON-serializable data (strings, numbers, plain objects/arrays).","If you must return non-serializable objects, store them out-of-band and return a reference/key, then hash the source."],"exampleFix":"// before\nconfig.setResult({ match: new RegExp(pattern) });\n\n// after\nconfig.setResult({ pattern });\nconfig.setCacheKey(createHash(pattern));","handlingStrategy":"validation","validationCode":"// If the result isn't serializable, set a manual cache key.\ntry {\n  serializeRaw(config.result);\n} catch {\n  config.setCacheKey(createHashFromInputs(config));\n}","typeGuard":"function isSerializable(value: mixed): boolean {\n  try { JSON.stringify(value); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  await serializeRaw(config.result);\n} catch (err) {\n  config.setCacheKey(manualHash);\n}","preventionTips":["Return only JSON-serializable config results when possible.","Call config.setCacheKey() whenever you return functions, regexes, or class instances.","Derive the manual key from stable inputs (file contents, versions), not runtime state."],"tags":["config","cache","serialization","plugin"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}