svelte: Application won't compile - "cannot read property 'n' of undefined" since 3.16.1
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 - https://github.com/sveltejs/svelte/commit/bb5cf9ada7706fed9bb86467d2ae78c76f88b9d0).
Logs
ant@xeno ~/Projects/beyonk-dashboard master ● npm run dev
beyonk-dashboard@0.3.0 dev /home/ant/Projects/beyonk-dashboard PORT=1233 NODE_CONFIG_ENV=${NODE_ENV} sapper 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
.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 17 (13 by maintainers)
Commits related to this issue
- fix bitmask overflow when using slotted components (#4077) — committed to Conduitry/svelte by Conduitry 5 years ago
- fix bitmask overflow when using slotted components (#4077) — committed to Conduitry/svelte by Conduitry 5 years ago
- fix bitmask overflow when using slotted components (#4077) — committed to Conduitry/svelte by Conduitry 5 years ago
- Merge pull request #4085 from Conduitry/gh-4077 fix bitmask overflow when using slotted components — committed to sveltejs/svelte by Rich-Harris 5 years ago
- fix bitmask overflow when using slotted components (#4077) — committed to taylorzane/svelte by Conduitry 5 years ago
This is what I meant by point #3 above. It’s not the sole cause though. You also need exactly 31 variable declarations.
I took the code from @dimfeld 's repro (thanks!) and took the
List.svelte
component out and started to trim it back.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:
Here’s a reproduction: https://svelte.dev/repl/5357a38fcfc6441ebcf162fa5d307a12?version=3.16.1
This just imports the
svelte-select
library. I haven’t reduced this to a minimal test case, but hopefully it helps you figure this out. It appears to be failing on the file List.svelte insidesvelte-select
.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.