{"record":{"id":"7b7d1a89ce80f706","repo":"sveltejs/kit","slug":"node-server-id-accessing-url-properties-in-a-p","errorCode":null,"errorMessage":"${node.server_id}: Accessing URL properties in a promise handler after `load(...)` has returned will not cause the function to re-run when the URL changes","messagePattern":"(.+?): Accessing URL properties in a promise handler after `load\\(\\.\\.\\.\\)` has returned will not cause the function to re-run when the URL changes","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/runtime/server/page/load_data.js","lineNumber":46,"sourceCode":"\t\tparent: false,\n\t\troute: false,\n\t\turl: false,\n\t\tsearch_params: new Set()\n\t};\n\n\tconst load = node.server.load;\n\t// TODO: shouldn't this be calculated using PageNodes? there could be a trailingSlash option on a layout\n\tconst slash = node.server.trailingSlash;\n\n\tif (!load) {\n\t\treturn { type: 'data', data: null, uses, slash };\n\t}\n\n\tconst url = make_trackable(\n\t\tevent.url,\n\t\t() => {\n\t\t\tif (DEV && done && !uses.url) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${node.server_id}: Accessing URL properties in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when the URL changes`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (is_tracking) {\n\t\t\t\tuses.url = true;\n\t\t\t}\n\t\t},\n\t\t(param) => {\n\t\t\tif (DEV && done && !uses.search_params.has(param)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${node.server_id}: Accessing URL properties in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when the URL changes`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (is_tracking) {\n\t\t\t\tuses.search_params.add(param);\n\t\t\t}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/server/page/load_data.js#L28-L64","documentation":"In server `load` functions, SvelteKit tracks which `url` properties your load function reads to know when to re-run it. If you access `url` inside a promise handler (e.g. inside `.then()` or after an `await`) after `load` has returned, the access happens too late to be tracked, so URL changes will not re-run the load function. This dev-mode warning flags that reactive dependency.","triggerScenarios":"A server `load` returns a promise (or defers work) that later reads `event.url` properties; `done` is true and `uses.url` was never set because earlier reads were not tracked.","commonSituations":"Awaiting a fetch inside `load` and reading `url.search` or `url.pathname` in the `.then()` callback; capturing `url` in a promise chain resolved after load completes.","solutions":["Read `url` properties synchronously at the top of `load`, before any `await` or promise continuation.","Capture needed values into local variables before awaiting, and use those inside the promise handler.","If the access is intentional one-shot logic, silence by ensuring the value is read before `load` returns."],"exampleFix":"// before\nexport function load({ url }) {\n  return fetchSomething().then((data) => ({ data, q: url.searchParams.get('q') }));\n}\n// after\nexport async function load({ url }) {\n  const q = url.searchParams.get('q');\n  const data = await fetchSomething();\n  return { data, q };\n}","handlingStrategy":"validation","validationCode":"export async function load({ url }) {\n  const path = url.pathname;\n  const q = url.searchParams.get('q');\n  // use only captured locals after this point\n  const data = await getData({ path, q });\n  return { data };\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read `url` properties before the first `await` in every load function.","Never reference the `url` object inside `.then()` callbacks.","Enable dev warnings in CI smoke tests to catch untracked reads early."],"tags":["load-function","reactivity","sveltekit","server"],"backgroundTag":"load-untracked-url-access","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}