-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: url.hash is inaccessible from load. Consider accessing hash from the page store within the script tag of your component. #6126
Comments
It's not technically a bug, though I can see why it would be frustrating. You are accessing |
Oh yeah, of course I can close the issue if this is not something to be reconsidered. |
If we wanted we could override |
(though we should override it anyway because it's currently revealing the hash) |
Ok, so the issue here is that Node behaves in a non-standard way — browsers will log the object just fine, but Node does things differently. We can fix it like this... import util from 'node:util';
export class LoadURL extends URL {
/** @returns {string} */
get hash() {
throw new Error(
'url.hash is inaccessible from load. Consider accessing hash from the page store within the script tag of your component.'
);
}
[util.inspect.custom]() {
return this.toString(); // or something that better resembles the current output
}
toString() {
return this.origin + this.pathname + this.search;
}
} ...but that doesn't work outside Node environments. Hmm. |
Describe the bug
Once I updated the latest svelte-kit version and above (x >
@sveltejs/kit@1.0.0-next.405
) I am getting the following error when I just try to use theurl
in the load function. As you can see from the repro I don't even try to access theurl.hash
but it still reports as it's illegal to do it.See the contents of
+layout.js
.Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-n4vmbd?file=src/routes/+layout.js
Logs
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: