Skip to content
Source
Sign inSign up
TanStack/virtual

Svelte virtualizer stores reset updated options when resubscribed #1355

Closedclean99(GitHub profile, opens in a new tab) opened this issue 0 comments

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

  1. In the reproduction directory, run npm ci and npm run repro.
  2. The script creates a virtualizer with 10 items, subscribes, and changes its count to 100.
  3. It removes the last subscription and subscribes to the same store again.
  4. Before unsubscribing, the count and total size are 100 4000. After resubscribing, they are 10 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.
  1. piecyk closed this

Sign in to join this conversation.