Skip to content

Svelte virtualizer stores reset updated options when resubscribed #1355

Closed

Description

@clean99

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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