Skip to content

Binding causes extra reactive call in child #8184

@zqianem

Description

@zqianem

Describe the bug

When a reactive statement is triggered in a child component, if another non-primitive dependency of that statement is bound to the parent component, the reactive statement will be run an extra time.

Ran into this when trying to use the Broadcast Channel API to sync bound Svelte variables across tabs. The extra call would cause infinite loops in sending messages between tabs.

Similar to #5720 but without the slot.

One workaround is to add <svelte:options immutable/> to the child component.

Reproduction

https://svelte.dev/repl/2b38363381f6400b9b9a8a870fbb7b24?version=3.55.1

Logs

No response

System Info

System:
    OS: Linux 6.1 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 5700G with Radeon Graphics
    Memory: 27.82 GB / 30.74 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.19.0 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.19.2 - /usr/bin/npm
  Browsers:
    Chromium: 108.0.5359.124
    Firefox: 108.0.2

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions