question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

missing params if route contains errors

See original GitHub issue

Describe the bug

If a route contains an error (unhandled fetch-requests, errors in a component, etc.) then the __error.svelte file gets rendered. This will also call the load function from the __layout.svelte file, like a normal request would do. Except that the params object is empty.

In a production application I use the slug to get the locale from the url e.g. /en/settings. When something fails then I no longer have the locale information in the params object and I need to use a workaround to get the locale.

const lang = params.lang || url.pathname.split('/')[1]

In this case it’s simple and I know the position of the param, but for other cases it would be good if the params could also be accessed when a error page is rendered.

Reproduction

Here is a demo repository with a short description in the README.md: https://github.com/ivanhofer/sveltekit-missing-params

Logs

No response

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz
    Memory: 2.63 GB / 7.66 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.volta/tools/image/node/16.13.1/bin/node
    Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
    npm: 8.1.2 - ~/.volta/tools/image/node/16.13.1/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.17 
    @sveltejs/kit: next => 1.0.0-next.251 
    svelte: ^3.44.0 => 3.46.3

Severity

serious, but I can work around it

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
EstebanBoraicommented, Feb 1, 2022

@Badlapje thanks for taking the time! Yeah Im applying the workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing Route Parameter errors - SOLVED - Laracasts
I'm upgrading an app from Laravel 5x to 6x, and I'm running into a series of errors regarding missing route parameters where I...
Read more >
Errors when parameters or arguments are missing for route
Trying to figure out a way to check to see if a parameter/argument is required for a route prior to attempting to checkAccess...
Read more >
Laravel 8 error. Missing Parameters in URL - Stack Overflow
I have already provided the parameter via route but still, there is an error. Code Screenshots are below. enter image description here enter ......
Read more >
Missing parameter for route when using glob pattern
Hi all, So I'm trying to change a couple of my routers to use the glob param pattern, in order to work with...
Read more >
Requests - Rocket Programming Guide
Query parameters are allowed to be missing. As long as a request's query string contains all of the static components of a route's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found