Skip to content
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

TypeError: Cannot read properties of undefined (reading 'default') after upgrading to 2.2.0 #262

Closed
Saibamen opened this issue Oct 23, 2023 · 13 comments · Fixed by #263
Closed

Comments

@Saibamen
Copy link

Saibamen commented Oct 23, 2023

at Router.svelte:45:28

Line 45: if (default_slot) default_slot.c();

This runtime error was introduced in svelte-routing 2.2.0.

Version 2.1.0 is OK.

Related: #258

@Saibamen Saibamen changed the title TypeError: Cannot read properties of undefined (reading 'default') after upgrading to 2.2.0 TypeError: Cannot read properties of undefined (reading 'default') after upgrading to 2.2.0 Oct 23, 2023
@krishnaTORQUE
Copy link
Collaborator

svelte version: ??
svelte-routing version: ??

@Saibamen
Copy link
Author

svelte: 4.2.2
svelte-routing 2.2.0

@krishnaTORQUE
Copy link
Collaborator

Can you please try latest version of svelte-routing?

@Saibamen
Copy link
Author

This same bug in 2.5.0

@krishnaTORQUE
Copy link
Collaborator

@motzel Could you please have look, Thanks

@motzel
Copy link
Contributor

motzel commented Oct 30, 2023

This line in the source code is completely different. The only places where the default property is read are:

const path = route.default ? basepath : route.path.replace(/\*.*$/, "");

const score = route.default

if (route.default) {

and none of them were changed in my PR. My guess is that the problem is in either of the last two, because the pick() function is used in Router.svelte. But I'm not able to reproduce it, it works for me.

@Saibamen Could you prepare a minimal example in which this bug appears? Or just replace route.default in these two lines in utils.js with route?.default and please check if it works.

@Saibamen
Copy link
Author

Saibamen commented Oct 30, 2023

Full stacktrace (version 2.2.0):

Uncaught TypeError: Cannot read properties of undefined (reading 'default')
    at Router.svelte:45:28
    at sync (index.js:150:19)
    at index.js:173:3
    at Object.subscribe2 [as subscribe] (index.js:82:11)
    at subscribe (utils.js:139:22)
    at component_subscribe (utils.js:159:31)
    at instance3 (Router.svelte:34:28)
    at init (Component.js:135:5)
    at new Router (Router.svelte:96:54)
    at create_fragment (Navigation.svelte:17:15)

image

@Saibamen
Copy link
Author

@motzel: I added ? to utils.js and Router.svelte and nothing was changed.
Error and stack trace is the same

@motzel
Copy link
Contributor

motzel commented Oct 30, 2023

@Saibamen This is all the way impossible, because there is no other reading of default property in the whole svelte-routing code. And even more so in line 45 of Router.svelte, because there is something else there. Could you please show the full stacktrace with the error? Although some minimal example of where the error occurs would be best.

@motzel
Copy link
Contributor

motzel commented Oct 30, 2023

Oh, I didn't notice that you already added the full stacktrace (I'm on mobile now), sorry

@motzel
Copy link
Contributor

motzel commented Oct 30, 2023

@Saibamen I have prepared a minimal example of svelte-routing (based on the documentation from the readme). It uses svelte-routing@2.2.0 and svelte@4.2.2, just like your project. Could you fork it and break it in the same way as in your project?

https://github.com/motzel/svelte-routing-example

@Saibamen
Copy link
Author

@motzel: Working version: https://github.com/Saibamen/svelte-routing-example/tree/2-1-0_working

image

Upgrade svelte-routing to version 2.2.0 and it will have this exception.

@motzel
Copy link
Contributor

motzel commented Oct 31, 2023

Thanks! I'll check it out today after work (~in 8h)

motzel added a commit to motzel/svelte-routing that referenced this issue Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants