Svelte virtualizer stores reset updated options when resubscribed #1355
Describe the bug#
After updating a virtualizer's count with setOptions, unsubscribing the last subscriber and subscribing again restores the initial count. This affects a long-lived store reused by a conditionally mounted list: its total size reverts when the list subscribes again.
Your minimal, reproducible example#
https://github.com/clean99/oss-pr-media/tree/main/tanstack-virtual/svelte-resubscribe-options
Steps to reproduce#
- In the reproduction directory, run
npm ciandnpm run repro. - The script creates a virtualizer with 10 items, subscribes, and changes its count to 100.
- It removes the last subscription and subscribes to the same store again.
- Before unsubscribing, the count and total size are
100 4000. After resubscribing, they are10 400, and the script exits with status 1.
Expected behavior#
The same store retains the updated count and total size: 100 4000.
How often does this bug happen?#
Every time.
Screenshots or Videos#
The reproduction prints the count and total size at each step.
Platform#
macOS, Node.js 24.8.0, Svelte 4.2.20. The reproduction exercises the store lifecycle directly without a browser.
tanstack-virtual version#
@tanstack/svelte-virtual 3.13.50
TypeScript version#
The reproduction uses JavaScript.
Additional context#
The existing unit-test setup also reproduces this with createWindowVirtualizer.
Terms & Code of Conduct#
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
piecyk closed this
Sign in to join this conversation.