{"record":{"id":"8e6868b2cbd1299b","repo":"parcel-bundler/parcel","slug":"invalid-backend-backend","errorCode":null,"errorMessage":"Invalid backend: ${backend}","messagePattern":"Invalid backend: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/workers/src/backend.js","lineNumber":31,"sourceCode":"\n  try {\n    require('worker_threads');\n    return 'threads';\n  } catch (err) {\n    return 'process';\n  }\n}\n\nexport function getWorkerBackend(backend: BackendType): Class<WorkerImpl> {\n  switch (backend) {\n    case 'threads':\n      return require('./threads/ThreadsWorker').default;\n    case 'process':\n      return require('./process/ProcessWorker').default;\n    case 'web':\n      return require('./web/WebWorker').default;\n    default:\n      throw new Error(`Invalid backend: ${backend}`);\n  }\n}\n","sourceCodeStart":13,"sourceCodeEnd":34,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/workers/src/backend.js#L13-L34","documentation":"Thrown by getWorkerBackend when the backend argument is not one of 'threads', 'process', or 'web'. The function maps a BackendType to a worker implementation class; an unknown value (or undefined) hits the default branch.","triggerScenarios":"Passing PARCEL_WORKER_BACKEND with a typo/invalid value (e.g. 'thread', 'processes', 'worker'), or constructing WorkerFarm with an explicit backend option that is not in the allowed set.","commonSituations":"Setting PARCEL_WORKER_BACKEND incorrectly; programmatic API misuse passing backend:'cluster'; stale docs suggesting an unsupported backend name.","solutions":["Set PARCEL_WORKER_BACKEND to 'threads' or 'process' (or omit it to auto-detect).","If passing backend in farmOptions, use one of 'threads' | 'process' | 'web'.","Unset the env var and let detectBackend() choose automatically."],"exampleFix":"// before\nPARCEL_WORKER_BACKEND=thread parcel build   // typo\n// or\nnew WorkerFarm({ backend: 'cluster' });\n\n// after\nPARCEL_WORKER_BACKEND=process parcel build\n// or\nnew WorkerFarm({ backend: 'process' });","handlingStrategy":"validation","validationCode":"const VALID_BACKENDS = new Set(['threads','process','web']);\nfunction normalizeBackend(b) {\n  if (b && !VALID_BACKENDS.has(b)) {\n    throw new Error(`Invalid backend '${b}'; use threads|process|web.`);\n  }\n  return b;\n}","typeGuard":"type BackendType = 'threads'|'process'|'web';\nfunction isValidBackend(b: string): b is BackendType {\n  return b === 'threads' || b === 'process' || b === 'web';\n}","tryCatchPattern":null,"preventionTips":["Validate PARCEL_WORKER_BACKEND against the allowed set in setup scripts.","Omit the env var to let detectBackend() auto-pick.","Document the backend names in your project README."],"tags":["worker-farm","backend","configuration","env-var"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}