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

[🐞] Passing undefined prop to a element ref causes crash when navigating #7142

Open
DustinJSilk opened this issue Dec 9, 2024 · 1 comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working

Comments

@DustinJSilk
Copy link
Contributor

Which component is affected?

Qwik Runtime

Describe the bug

When using a component similar to the below, when you navigate to the page which renders the component, the website crashes with the following error:

Cannot set property value of #<SignalDerived> which has only a getter TypeError: Cannot set property value of #<SignalDerived> which has only a getter

This is the error producing code:

import { component$, type Signal } from "@builder.io/qwik";

export const Foo = component$((props: { ref?: Signal<HTMLElement> }) => {
  const Tag = Math.random() ? "div" : "span";

  return <Tag ref={props.ref}>Foo element</Tag>;
});

export default component$(() => {
  return <Foo />;
});

Reproduction

https://github.com/DustinJSilk/qwik-ref-undefined

Steps to reproduce

  • pnpm i
  • pnpm start
  • Click on "Go to error page"
  • Open console and view error

System Info

System:
    OS: macOS 15.1.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 2.37 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
    pnpm: 9.0.5 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 131.0.6778.109
    Safari: 18.1.1
  npmPackages:
    @builder.io/qwik: ^1.11.0 => 1.11.0 
    @builder.io/qwik-city: ^1.11.0 => 1.11.0 
    typescript: 5.4.5 => 5.4.5 
    undici: * => 7.1.0 
    vite: 5.3.5 => 5.3.5

Additional Information

  • This does not happen when you simply pass in undefined to the ref
  • This does not happen unless you use a dynamic tag
  • I could not get this issue to happen in stackblitz, I can never really get stackblitz to work.
    Please clone the repository to test.
@DustinJSilk DustinJSilk added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Dec 9, 2024
@gioboa
Copy link
Member

gioboa commented Dec 10, 2024

Qwik v2 is failing too

QWIK ERROR WrappedSignal is read-only Error: WrappedSignal is read-only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants