Skip to content

Race condition in initalization #1

Description

@torresmi

Description

If you dispatch an action soon after creating the epic middleware, the returned Observable from the map function needs to start the subscription synchronously. If you subscribe with a different scheduler (subscribeOn), a race condition is created and events could be emitted before subscribers are ready.

Steps to reproduce the behavior

On the "create" test here Tests, make the returned observable subscribe on a different scheduler. Eg. .subscribeOn(Schedulers.io())

Investigation

At this point it is assumed that the actions subject has observers, however the actions.hasObservers() function shows that is not true.
What I think is happening is that since we are subscribing on a different thread in the epic observable, the function continues and emits an item before the observable is ready to receive items.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions