sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
78.15k stars 4.08k forks source link

`<svelte:component>` wrong error message on component creation #12446

Closed fsoft72 closed 1 month ago

fsoft72 commented 1 month ago

Describe the bug

During the <svelte:component> definition, if a generic function is invoked in the params definition and that function is missing, the error returned is svelte_component_invalid_this_value, while the component is a perfectly working svelte component.

This happens because in: /svelte/src/internal/client/validate.js there is this line

if (typeof message === 'string' && message.indexOf('is not a function') !== -1)

that raises the svelte_component_invalid_this_value(); wrongly

Reproduction

I have created a REPL here

As you can see on line 33, the last parameter is undefined and this throws the error function is not defined on line 27 which will be misinterpreted by Svelte

Logs

No response

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04 LTS 24.04 LTS (Noble Numbat)
    CPU: (24) x64 AMD Ryzen 9 7900X 12-Core Processor
    Memory: 51.92 GB / 62.01 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 9.5.0 - ~/.local/share/pnpm/pnpm
    bun: 1.0.0 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 125.1.66.115
    Chrome: 126.0.6478.114

Severity

blocking an upgrade

paoloricciuti commented 1 month ago

Severity

blocking an upgrade

I agree the error message could be better but how is this blocking an upgrade?

I will try to check if it's possible to throw a more descriptive error

fsoft72 commented 1 month ago

It is not blocking the upgrade, but bug levels are "annoying", "blocking upgrade" and "blocking all usages of svelte"... I think this is more than annoying, but not so critical to block all usages of svelte. And tt is not just the error message, it is the fact that it pointed me to debug the wrong part of code. Today I spent a lot of time trying to understand what was wrong inside the component function, when it wasn't it at all.