Skip to content

Svelte 5: $derived doesn't update if $state is created and read outside of a reactive context #11065

@ampatspell

Description

@ampatspell

Describe the bug

This is a followup of #10930

5.0.0-next.91 didn't fix issues I'm having with async callbacks that create/update models with $state properties

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE6VSTW-jMBD9KyOrUkBCYc_5oOpxL3vqaetKMXhIrIKNPEPaCvHfK2NIUzU9FSRkz7yZ9-Yxg6hNgyQ2T4OwqkWxEQ9dJzLB71240BkbRpEJcr2vQmRHlTcdQ6PscS8FkxRQOcv4xnspWqf7BqUopAXAt855hqpRRPB4MvYIQ4gDaMUK9nBHrBh3AwTqDRD7gBmLJN1KG5HUl4GwxCRdigEI-dG06HpOkhT2xWcGgE-G1nP_qzDMHIf_iKWCf2iOp1Idsk_EuF3OYwZ_0vk2LkJCeZCs0Zsz6uTCc78OqYif0d8Hp0ULTzZcRp-Sv5936WrxNfIl6fYWZH3V_kIZnjwPdQSlR_VCUeU0F8zzSis5vnkOf2uoXNuiZdTges7g0DqNTSSJhhzAo9XoCSrnPVbcvN9UFLA_OT99dnncuCLovbF906o1yDBJuDaBZhfusK6xWryLSq-MCKCvJNqci_l_r4Zvk42rXR4Q0oosLLypDWqxYd_j-Dx-AC6d6h5SAwAA

Logs

No response

System Info

System:
  OS: macOS 14.4.1
  CPU: (8) arm64 Apple M1
  Memory: 105.23 MB / 8.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
  Yarn: 1.22.21 - ~/.nvm/versions/node/v18.19.0/bin/yarn
  npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
  pnpm: 8.15.5 - ~/.nvm/versions/node/v18.19.0/bin/pnpm
  bun: 1.0.15 - ~/.bun/bin/bun
  Watchman: 2023.12.04.00 - /opt/homebrew/bin/watchman
Browsers:
  Chrome: 123.0.6312.105
  Safari: 17.4.1
npmPackages:
  svelte: 5.0.0-next.94 => 5.0.0-next.94

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions