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

Cannot read property 'p' of undefined #4629

Closed
dritter opened this issue Apr 4, 2020 · 6 comments
Closed

Cannot read property 'p' of undefined #4629

dritter opened this issue Apr 4, 2020 · 6 comments
Labels

Comments

@dritter
Copy link

dritter commented Apr 4, 2020

Describe the bug
If you open this REPL and click on "3", the console shows the following error:

message: "Uncaught (in promise): Cannot read property 'p' of undefined"
stack: TypeError: Cannot read property 'p' of undefined
at Object.update [as p] (eval at handle_message (about:srcdoc:13:8), <anonymous>:496:17)
at Object.update [as p] (eval at handle_message (about:srcdoc:13:8), <anonymous>:563:26)
at update (eval at handle_message (about:srcdoc:13:8), <anonymous>:161:40)
at flush (eval at handle_message (about:srcdoc:13:8), <anonymous>:130:17)

Not sure, if I am doing something wrong here. I wasn't able to debug this properly.. At least, I didn't find a similar bug report.

Thanks for any hints.

@Conduitry Conduitry added the awaiting submitter needs a reproduction, or clarification label Apr 5, 2020
@Conduitry
Copy link
Member

There seems to be some bug here that I'm not too clear on, but your component still wouldn't work anyway, because Svelte won't know to rerun isInRange when activePage changes. Functions in the template are re-run when any of their arguments change, not when additional variables the function bring in from a higher scope are changed.

@dritter
Copy link
Author

dritter commented Apr 5, 2020

Ha! Thanks! Indeed, passing the activePage in isInRange function avoids the error.

I'd like to keep this issue open, as the error is still somewhere around. Feel free to close it anways ;)

@antony
Copy link
Member

antony commented Apr 9, 2020

@dritter would it be possible to create a simpler repro (with code that would eventually work) that way we might be able to debug this and find a fix?

@dritter
Copy link
Author

dritter commented Apr 14, 2020

Hi @antony ,
unfortunately I wasn't able to reproduce it with working code. But I managed to strip the example a bit down (works with a synthetic click). Interesting is that if I reduce the amount of pages to 7 or remove the class:active={currentPage === activePage} binding, the error disappears..

Btw. is there a way to easily test #4633 ?

@pushkine
Copy link
Contributor

pushkine commented Apr 14, 2020

it is fixed in the PR
I wish you could test changes made to the compiler in the REPL though

new folder
git clone https://github.com/pushkine/svelte/tree/patch-2
npm install
npm run dev
npm link

new folder
npx degit sveltejs/template
npm link svelte
npm install
copy paste your repl components into src
npm run dev
localhost:5000

@antony antony added bug has pr and removed awaiting submitter needs a reproduction, or clarification labels Apr 15, 2020
@Conduitry
Copy link
Member

The other issues with the example itself remain, but the bug this revealed is fixed in 3.21.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants