Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store with start callback may double-call its first subscriber #3022

Closed
PixievoltNo1 opened this issue Jun 14, 2019 · 1 comment · Fixed by #3107
Closed

Store with start callback may double-call its first subscriber #3022

PixievoltNo1 opened this issue Jun 14, 2019 · 1 comment · Fixed by #3107
Labels

Comments

@PixievoltNo1
Copy link

PixievoltNo1 commented Jun 14, 2019

Steps to reproduce:

  1. Create a writable/readable store with a start callback that synchronously calls its set callback. (Note: derived creates such a store when its own callback is synchronous.)
  2. Subscribe with any number of subscribers, then unsubscribe them all.
  3. Subscribe with a "new first subscriber".

Expected results: Each subscriber gets called exactly once upon subscribing, no matter what.

Actual results: The "new first subscriber" is called twice. REPL

Looking at the source code, I see set tries to guard against this, but it doesn't always work because stop isn't always falsy when needed. That could be fixed, but maybe we don't need the guard at all - why does subscribe add the subscriber before calling start? Can we safely reverse that?

PixievoltNo1 added a commit to PixievoltNo1/svelte-writable-derived that referenced this issue Jun 14, 2019
@Conduitry Conduitry added the bug label Jun 22, 2019
Rich-Harris added a commit that referenced this issue Jun 25, 2019
only call subscriber once for writable with callback
@Rich-Harris
Copy link
Member

Fixed in 3.6.0 — thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants