{"record":{"id":"cfc552c9593a6b09","repo":"anomalyco/sst","slug":"failed-to-load-cloudflare-unenv-config-w-s","errorCode":null,"errorMessage":"failed to load cloudflare unenv config: %w\n%s","messagePattern":"failed to load cloudflare unenv config: %w\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/worker/worker.go","lineNumber":261,"sourceCode":"\n\tw.lock.RLock()\n\tif cached, ok := w.unenv[key]; ok {\n\t\tw.lock.RUnlock()\n\t\treturn cached, nil\n\t}\n\tw.lock.RUnlock()\n\n\tcmd := process.CommandContext(\n\t\tctx,\n\t\t\"node\",\n\t\tfilepath.Join(path.ResolvePlatformDir(cfgPath), \"src/runtime/worker/unenv.mjs\"),\n\t\tstring(payload),\n\t)\n\tcmd.Dir = path.ResolvePlatformDir(cfgPath)\n\tcmd.Env = []string{}\n\toutput, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load cloudflare unenv config: %w\\n%s\", err, output)\n\t}\n\n\tvar result unenv\n\tif err := json.Unmarshal(output, &result); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode cloudflare unenv config: %w\\n%s\", err, output)\n\t}\n\n\tw.lock.Lock()\n\tw.unenv[key] = &result\n\tw.lock.Unlock()\n\n\treturn &result, nil\n}\n\nfunc (w *Runtime) Match(runtime string) bool {\n\treturn runtime == \"worker\"\n}\n","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/worker/worker.go#L243-L279","documentation":"The worker (Cloudflare Workers) runtime determines Node.js compat polyfills by spawning `node src/runtime/worker/unenv.mjs` with the project's compatibility flags. This error means the child Node process exited non-zero; the script's combined stdout/stderr is appended to help diagnose why. unenv config resolution is required before esbuild can bundle, so the build aborts.","triggerScenarios":"Running `sst deploy`/`sst dev` for a `worker` runtime component when the spawned `node unenv.mjs` fails: node not on PATH, the script throws (missing `unenv` dependency in the platform dir), or an invalid `compatibility_date`/`compatibility_flags` payload.","commonSituations":"No Node.js installed or wrong version on the machine; corrupted or partially installed `node_modules` under `.sst/platform`; unsupported compatibility date string passed in `sst.config.ts`; empty `cmd.Env` hiding needed env vars.","solutions":["Ensure `node` (>=18) is installed and on PATH: `node -v`","Delete `.sst/` and reinstall platform deps (`bun install` / `npm install` in the platform dir), then retry","Check your `worker` component's `compatibilityDate`/`compatibilityFlags` values against valid Cloudflare dates","Run the script manually to see the full error: `cd .sst/platform/src/runtime/worker && node unenv.mjs '{}'`"],"exampleFix":"// before (sst.config.ts)\ncompatibilityDate: \"2099-01-01\"\n// after\ncompatibilityDate: \"2025-01-01\"","handlingStrategy":"try-catch","validationCode":"// before deploy, ensure node is available and the platform script exists\nexecSync(\"node -v\", { stdio: \"inherit\" });\nconst script = path.join(\".sst/platform/src/runtime/worker/unenv.mjs\");\nif (!fs.existsSync(script)) throw new Error(\"platform not installed; run sst setup / reinstall\");","typeGuard":null,"tryCatchPattern":"try {\n  await run(\"sst\", [\"deploy\"]);\n} catch (e) {\n  if (/failed to load cloudflare unenv config/.test(String(e))) {\n    console.error(\"unenv.mjs failed; output was:\\n\" + String(e).split(\"\\n\").slice(1).join(\"\\n\"));\n    // common remedy: reinstall platform deps\n    await exec(\"rm\", [\"-rf\", \".sst\"]);\n    await run(\"sst\", [\"deploy\"]); // or instruct user to reinstall\n  } else throw e;\n}","preventionTips":["Keep Node.js >= 18 on PATH in dev and CI","Never hand-edit `.sst/platform` scripts; reinstall platform artifacts after SST upgrades","Validate compatibilityDate/compatibilityFlags values before deploy","Ensure a clean, complete `npm install`/`bun install` of platform dependencies"],"tags":["worker","cloudflare","node","build","subprocess"],"backgroundTag":"node-child-process-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}