{"record":{"id":"f1d5fce77bb773d9","repo":"sveltejs/kit","slug":"node-server-id-accessing-route-string-key","errorCode":null,"errorMessage":"${node.server_id}: Accessing `route.${String(key)}` in a promise handler after `load(...)` has returned will not cause the function to re-run when the route changes","messagePattern":"(.+?): Accessing `route\\.(.+?)` in a promise handler after `load\\(\\.\\.\\.\\)` has returned will not cause the function to re-run when the route changes","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/runtime/server/page/load_data.js","lineNumber":148,"sourceCode":"\t\t\t\t\t\t\treturn target[/** @type {string} */ (key)];\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\tparent: async () => {\n\t\t\t\t\t\tif (DEV && done && !uses.parent) {\n\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t`${node.server_id}: Calling \\`parent(...)\\` in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when parent data changes`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (is_tracking) {\n\t\t\t\t\t\t\tuses.parent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn parent();\n\t\t\t\t\t},\n\t\t\t\t\troute: new Proxy(event.route, {\n\t\t\t\t\t\tget: (target, key) => {\n\t\t\t\t\t\t\tif (DEV && done && typeof key === 'string' && !uses.route) {\n\t\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t\t`${node.server_id}: Accessing \\`route.${String(\n\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t)}\\` in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when the route changes`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (is_tracking) {\n\t\t\t\t\t\t\t\tuses.route = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn target[/** @type {'id'} */ (key)];\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\turl,\n\t\t\t\t\tuntrack(fn) {\n\t\t\t\t\t\tis_tracking = false;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn fn();\n\t\t\t\t\t\t} finally {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/server/page/load_data.js#L130-L166","documentation":"SvelteKit proxies `route` (the matched route's `id`/params metadata) in server `load` to track reads. Accessing `route` in a promise handler after `load` has returned escapes tracking, so navigating between routes will not re-run the load function as expected.","triggerScenarios":"Server `load` reads `route.id` (or another `route` property) inside a `.then()`/post-await continuation after the body completed and `uses.route` was never set during tracking.","commonSituations":"Logging the route id in an async callback; branch-specific logic that reads `route.id` only after data resolves.","solutions":["Read `route.id` (and any other route properties) synchronously at the top of `load`.","Capture the route id into a local variable before awaiting and use that in continuations.","Remove post-return route access if it was only for diagnostics."],"exampleFix":"// before\nexport function load({ route }) {\n  return getData().then((d) => ({ d, routeId: route.id }));\n}\n// after\nexport async function load({ route }) {\n  const routeId = route.id;\n  const d = await getData();\n  return { d, routeId };\n}","handlingStrategy":"validation","validationCode":"export async function load({ route }) {\n  const routeId = route.id; // read synchronously\n  const data = await getData(routeId);\n  return { data };\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read `route.id` before the first `await` in load functions.","Pass the captured routeId into async helpers instead of the `route` proxy.","Audit load functions with `.then()` chains for late `route` access."],"tags":["load-function","route","sveltekit","server"],"backgroundTag":"load-untracked-route-access","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}