{"action":"created","issue":{"url":"https://api.github.com/repos/zenparsing/es-observable/issues/47","labels_url":"https://api.github.com/repos/zenparsing/es-observable/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/zenparsing/es-observable/issues/47/comments","events_url":"https://api.github.com/repos/zenparsing/es-observable/issues/47/events","html_url":"https://github.com/zenparsing/es-observable/issues/47","id":96906891,"number":47,"title":"Should this spec route errors occurring in the next handler to the error handler?","user":{"login":"blesh","id":1540597,"avatar_url":"https://avatars.githubusercontent.com/u/1540597?v=3","gravatar_id":"","url":"https://api.github.com/users/blesh","html_url":"https://github.com/blesh","followers_url":"https://api.github.com/users/blesh/followers","following_url":"https://api.github.com/users/blesh/following{/other_user}","gists_url":"https://api.github.com/users/blesh/gists{/gist_id}","starred_url":"https://api.github.com/users/blesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blesh/subscriptions","organizations_url":"https://api.github.com/users/blesh/orgs","repos_url":"https://api.github.com/users/blesh/repos","events_url":"https://api.github.com/users/blesh/events{/privacy}","received_events_url":"https://api.github.com/users/blesh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-07-23T21:14:09Z","updated_at":"2015-07-30T04:25:01Z","closed_at":null,"body":"I was talking with @trxcllnt today about the behavior the occurs when you throw in an next handler... \r\n\r\nFor example:\r\n\r\n```js\r\nmyObservable.subscribe((x) => {\r\n  // ReferenceError:  let's say x.foo is undefined here.\r\n  someSideEffect(x.foo.blah);\r\n}, err => {\r\n   reportAnError(err);\r\n});\r\n```\r\nCurrently, it will just throw, and will *not* go to the error handler.\r\n\r\nThis results in people using RxJS like this as a \"best practice\", which isn't at all a \"best practice\", because `do` and `doAction` will route thrown errors down the error path:\r\n\r\n```js\r\nmyObservable.doAction((x) => {\r\n  someSideEffect(x.foo.blah);\r\n})\r\n.subscribe(noop, (err) => {\r\n  reportAnError(err);\r\n});\r\n```\r\n\r\nApparently teams at Netflix even have their own forks of RxJS that have patched the the onNext handler call to route to the onError handler if it throws."},"comment":{"url":"https://api.github.com/repos/zenparsing/es-observable/issues/comments/126178571","html_url":"https://github.com/zenparsing/es-observable/issues/47#issuecomment-126178571","issue_url":"https://api.github.com/repos/zenparsing/es-observable/issues/47","id":126178571,"user":{"login":"trxcllnt","id":178183,"avatar_url":"https://avatars.githubusercontent.com/u/178183?v=3","gravatar_id":"","url":"https://api.github.com/users/trxcllnt","html_url":"https://github.com/trxcllnt","followers_url":"https://api.github.com/users/trxcllnt/followers","following_url":"https://api.github.com/users/trxcllnt/following{/other_user}","gists_url":"https://api.github.com/users/trxcllnt/gists{/gist_id}","starred_url":"https://api.github.com/users/trxcllnt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trxcllnt/subscriptions","organizations_url":"https://api.github.com/users/trxcllnt/orgs","repos_url":"https://api.github.com/users/trxcllnt/repos","events_url":"https://api.github.com/users/trxcllnt/events{/privacy}","received_events_url":"https://api.github.com/users/trxcllnt/received_events","type":"User","site_admin":false},"created_at":"2015-07-30T04:25:01Z","updated_at":"2015-07-30T04:25:01Z","body":"@blesh @zenparsing The `next` callback throwing an error, and the Observer receiving an `error` message are two separate behaviors. As described in the [Rx Design Guidelines (PDF)](http://go.microsoft.com/fwlink/?LinkID=205219):\r\n> Observables should send zero or more *onNext* messages, followed by either an *onCompleted* or *onError* (but not both), and no more messages should arrive after an *onError* or *onCompleted* message.\r\n\r\nAfter an Observer's `error` callback is invoked, the Observable must not message the Observer again. If the `error` callback hasn't been invoked yet, as would be the case if `next` throws an error, it's still valid to invoke the `error` callback.\r\n\r\nDo you have a real-world example in which invoking `error` after `next`, even if `next` throws, isn't safe on a spec-conforming Observer?"}}