Skip to content

Scheduling should serialize notifications. #3542

Closed
@Dorus

Description

@Dorus

Currently, onError cuts ahead of onNext calls when you schedule work, but does not (cannot) when you use a single thread.

Observable.create(o -> {
    o.onNext(1);
    o.onError(new NotImplementedException());
})
.observeOn(Schedulers.newThread())
.subscribe(i -> System.out.println(i), 
        e -> System.out.println("error:" + e));

This yields error instead of 1, error as expected. Other implementations of Rx like Rx.Net do serialize notifications. This 'cut ahead' behavior is actually described as a common pitfall in RxJava by some.

Activity

akarnokd

akarnokd commented on Nov 27, 2015

@akarnokd
Member

RxJava 2.0 will allow you to customize this behavior in many operators, including observeOn, delay, combineLatest, zip, groupBy, onBackpressureBuffer, skipLast and takeLast.

I was planning to post a PR targeting observeOn to remove some unnecessary code (#3002) and may well do this as well.

Dorus

Dorus commented on Dec 3, 2015

@Dorus
Author

This is really scary nondeterministic behavior, and against Rx contract. I hope the (future) default will be to not lose data. If anything it might be an appropriate setting on the subscriber.

akarnokd

akarnokd commented on Mar 14, 2016

@akarnokd
Member

The observeOn operator received an overload that takes a delayError parameter you can set.

Closing via #3682.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @akarnokd@Dorus

        Issue actions

          Scheduling should serialize notifications. · Issue #3542 · ReactiveX/RxJava