{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxAndroid/issues/155","labels_url":"https://api.github.com/repos/ReactiveX/RxAndroid/issues/155/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxAndroid/issues/155/comments","events_url":"https://api.github.com/repos/ReactiveX/RxAndroid/issues/155/events","html_url":"https://github.com/ReactiveX/RxAndroid/issues/155","id":69146077,"number":155,"title":"onNext not called if onError is called immediately after when Scheduler is defined in observeOn","user":{"login":"mariusgreve","id":414149,"avatar_url":"https://avatars.githubusercontent.com/u/414149?v=3","gravatar_id":"","url":"https://api.github.com/users/mariusgreve","html_url":"https://github.com/mariusgreve","followers_url":"https://api.github.com/users/mariusgreve/followers","following_url":"https://api.github.com/users/mariusgreve/following{/other_user}","gists_url":"https://api.github.com/users/mariusgreve/gists{/gist_id}","starred_url":"https://api.github.com/users/mariusgreve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariusgreve/subscriptions","organizations_url":"https://api.github.com/users/mariusgreve/orgs","repos_url":"https://api.github.com/users/mariusgreve/repos","events_url":"https://api.github.com/users/mariusgreve/events{/privacy}","received_events_url":"https://api.github.com/users/mariusgreve/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-17T14:10:53Z","updated_at":"2015-04-17T15:34:17Z","closed_at":"2015-04-17T14:26:57Z","body":"If I set a `Scheduler` in `.observeOn(...)` for an `Observable` and call `subscriber.onError` immediately after `subscriber.onNext`, `onNext` is never called in my `Observer`.\r\n\r\nIf I either add a sleep between `subscriber.onNext` and `subscriber.onError` or don't set a `Scheduler` in `.observeOn(...)`, `onNext` is called in my `Observer`.\r\n\r\nSee example:\r\n\r\n```java\r\nObservable.create(new Observable.OnSubscribe<String>() {\r\n\t@Override\r\n\tpublic void call(Subscriber<? super String> subscriber) {\r\n\t\tsubscriber.onNext(\"Test\");\r\n\t\tsubscriber.onError(null);\r\n\t}\r\n}).observeOn(AndroidSchedulers.mainThread())\r\n\t\t.subscribe(new Observer<String>() {\r\n\t\t\t@Override\r\n\t\t\tpublic void onCompleted() {\r\n\t\t\t\tSystem.out.println(\"onCompleted\");\r\n\t\t\t}\r\n\r\n\t\t\t@Override\r\n\t\t\tpublic void onError(Throwable e) {\r\n\t\t\t\tSystem.out.println(\"onError\");\r\n\t\t\t}\r\n\r\n\t\t\t@Override\r\n\t\t\tpublic void onNext(String s) {\r\n\t\t\t\tSystem.out.println(\"onNext\");\r\n\t\t\t}\r\n\t\t});\r\n\r\n// Only prints \"onError\", but should print \"onNext\" and then \"onError\"\r\n```"},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxAndroid/issues/comments/94010460","html_url":"https://github.com/ReactiveX/RxAndroid/issues/155#issuecomment-94010460","issue_url":"https://api.github.com/repos/ReactiveX/RxAndroid/issues/155","id":94010460,"user":{"login":"mttkay","id":102802,"avatar_url":"https://avatars.githubusercontent.com/u/102802?v=3","gravatar_id":"","url":"https://api.github.com/users/mttkay","html_url":"https://github.com/mttkay","followers_url":"https://api.github.com/users/mttkay/followers","following_url":"https://api.github.com/users/mttkay/following{/other_user}","gists_url":"https://api.github.com/users/mttkay/gists{/gist_id}","starred_url":"https://api.github.com/users/mttkay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mttkay/subscriptions","organizations_url":"https://api.github.com/users/mttkay/orgs","repos_url":"https://api.github.com/users/mttkay/repos","events_url":"https://api.github.com/users/mttkay/events{/privacy}","received_events_url":"https://api.github.com/users/mttkay/received_events","type":"User","site_admin":false},"created_at":"2015-04-17T15:34:17Z","updated_at":"2015-04-17T15:34:17Z","body":"This is interesting. Could you backlink the issue here?\r\n\r\nI think the reason this is happening is because `onError` is a terminal state, and `DefaultSubscriber` unsubscribes itself in terminal states. What I imagine might be happening is that unsubscribing happens before the operator gets a change to deliver the `next` notification (although you call them in succession, they will do a round trip through Android's message loop.)\r\n\r\nThat said, this may or may not be a problem with RxJava core."}}