{"record":{"id":"8ef9b55eb0ec509c","repo":"remix-run/remix","slug":"route-map-loader-returned-an-invalid-tree","errorCode":null,"errorMessage":"Route-map loader returned an invalid tree.","messagePattern":"Route-map loader returned an invalid tree\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/lib/route-map.ts","lineNumber":230,"sourceCode":"    let directory = directoriesByRouteName.get(rawNode.name)\n\n    if (directory == null) {\n      throw routeOwnerPlanUnresolved(rawNode.name)\n    }\n\n    return {\n      exists: directory.exists,\n      kind: 'directory',\n      path: directory.directoryPath,\n    }\n  }\n\n  throw routeOwnerPlanUnresolved(rawNode.name)\n}\n\nfunction assertRawRouteTree(value: unknown): RawRouteTreeNode[] {\n  if (!Array.isArray(value)) {\n    throw new Error('Route-map loader returned an invalid tree.')\n  }\n\n  return value.map((entry) => assertRawRouteTreeNode(entry))\n}\n\nfunction assertRawRouteTreeNode(value: unknown): RawRouteTreeNode {\n  if (typeof value !== 'object' || value == null) {\n    throw new Error('Route-map loader returned an invalid route node.')\n  }\n\n  let key = Reflect.get(value, 'key')\n  let name = Reflect.get(value, 'name')\n  let kind = Reflect.get(value, 'kind')\n  let children = Reflect.get(value, 'children')\n\n  if (typeof key !== 'string' || typeof name !== 'string') {\n    throw new Error('Route-map loader returned a route node without a valid name.')\n  }","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/cli/src/lib/route-map.ts#L212-L248","documentation":"The route-map loader runs a worker that JSON-serializes the parsed route tree back to the main process. If the deserialized payload is not an array, this assertion fails — almost always a version mismatch or corrupted IPC, not a user config issue.","triggerScenarios":"loadRawRouteMap receives a worker response whose top-level value is not an array (e.g. an object, string, or error payload parsed as data).","commonSituations":"Mixed CLI versions in node_modules (worker from one remix version, spawner from another); pnpm hoisting weirdness; manually mocking the worker response in tests.","solutions":["Reinstall dependencies (`rm -rf node_modules && pnpm install`) to align CLI versions","Deduplicate remix/CLI packages: `pnpm why remix` and pin a single version","If mocking in tests, return a RawRouteTreeNode[] array from the mock"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!Array.isArray(await workerResult)) throw new Error('unexpected worker payload')","typeGuard":"const isTree = (v: unknown): v is unknown[] => Array.isArray(v)","tryCatchPattern":"try { await loadRawRouteMap(...) } catch (e) { if (String(e.message).includes('invalid tree')) { await cleanReinstall() } throw e }","preventionTips":["Pin a single remix version across the workspace","Deduplicate with pnpm why / overrides","Regenerate worker fixtures from real output"],"tags":["routes","worker","internal","version-mismatch"],"backgroundTag":"invalid-worker-response","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}