Skip to content

Proxy Store does not work in components with Auto-Subscription but works in components without Auto-Subscription #5019

@firewave-remo

Description

@firewave-remo

Describe the bug
I have implemented my own store with a proxy implementation, so that i don't have to call store.set(...) or store.update(...).

This works perfectly fine if the store is used in a component without Auto-Subscription of the store. But as soon as the store is used in a component which Auto-Subscribes the store, the app crashes and doesn't even show the page. Just a console error Cannot read property 'foo' of undefined. Even though the implementation is exactly the same.

To Reproduce
Repl:
https://svelte.dev/repl/c1b53139e2bb45be8eec3f23d5530770?version=3.23.2

First click on the button Change Foo in Test.svelte. Everything works as expected. Then try to uncomment // proxyStore.foo = "Bar"; in App.svelte and you will see the error Cannot read property 'foo' of undefined

Expected behavior
No errors are shown and changing the property of the store should work also in the component that uses Auto-Subscription

Information about your Svelte project:

  • Chrome

  • Linux Mint

  • Svelte version 3.23.2

  • Rollup

Severity
Very annoying bug. Unexpected behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions