-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Application won't compile - "cannot read property 'n' of undefined" since 3.16.1 #4077
Comments
Presumably #4063 was an incomplete fix. Please do update with a repro if you find one. |
This script should try to compile all components in the project and allow the full stack trace and breakpoints using the built-in Node debugger. Not sure if it needs tweaking for sapper though.
|
I believe this line is the issue:
We could temporarily fix it by checking for |
This line should probably just initialize bitmask to contain an object since we'll always need at least one of them.
Should be:
Burning question is still how did the bitmask object get initialized not containing an index 0 in the first place! |
Contrary to what I assumed earlier, I see that |
Here's a reproduction: https://svelte.dev/repl/5357a38fcfc6441ebcf162fa5d307a12?version=3.16.1 This just imports the
|
I took the code from @dimfeld 's repro (thanks!) and took the This is as minimal as I can get it without making the error disappear: https://svelte.dev/repl/909f45b7a2234ad2804d3dcecd59a54b?version=3.16.1 It seems to occur when you have exactly 31 variables declared and a component declaration. Note:
|
<A>
</A> The error goes away if you write |
Great, thanks for the minimal repro, folks! edit: It looks like the necessary condition for this to manifest is actually that there be some content passed to the component. The carriage return isn't important, but it does count as content to be passed to the child component. |
One way to address this looks like it would be to replace if (!bitmask[i]) bitmask[i] = { n: 0, names: [] }; with if (bitmask.length <= i) {
for (let j = bitmask.length; j <= i; j++) {
bitmask[j] = { n: 0, names: [] };
}
} so that we fill in the missing elements in the |
Just was chatting with @mrkishi and it looks like the issue is that The obvious solution is to defer calculating Edit: I think it'll be safe just to move |
Fully admit that this part of the code is completely bewildering. The idea behind setting {#each things as thing}
<p>{thing}</p>
{/each} ...then Certainly possible — likely, even — that there's a much neater way to do all this without causing unnecessary overflows. |
I also just noticed that the code-red issue I was seeing would be fixed in #4078, so I'm glad I don't have to worry about that. If I rebase moving But I also see now why that was an issue at all - we were now being overly cautious in saying there was a context overflow in many situations. Blargh. I dunno. I guess the issue is that some of the things added during render really do need to be part of the context and others do not. |
Hmm. Well I'll merge #4078 as-is and cut a release, because I need it for work. We could certainly move the assignment down to guarantee correctness, and then worry about eliminating false positives later |
I'd also initialize bitmask with the first index populated since we'll always need it anyway...
|
fix bitmask overflow when using slotted components
Describe the bug
Upgrading an existing app to Svelte 3.16.1 causes client compilation to fail with the error
Cannot read property 'n' of undefined
.I'm the second person to see this in the discord, it seems. I don't know where the error comes from or what the causes is (but I do see that the variable
n
is used a lot in recent Svelte commits - bb5cf9a).Logs
ant@xeno ~/Projects/beyonk-dashboard master ● npm run dev
✗ client
Cannot read property 'n' of undefined
To Reproduce
I'm afraid I simply don't know, at present.
Expected behavior
The client should compile as normal.
Information about your Svelte project:
Your operating system: Ubuntu 19.04
Svelte version 3.16.1
Rollup
Severity
Blocker. It's broken, and my app won't start.
Additional context
The app was previously using 3.15, and trying 3.16.0 wouldn't start either, due to an issue with
reduce with no initial value
.The text was updated successfully, but these errors were encountered: