fix(Observable): Another attempt at fixing error rethrows in v5 #3161
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an attempt at fixing the rethrow issues in #2813. Some of them have been fixed by previous PRs, but other cases still remain. So far every one I've seen has been fixed by this PR.
I'll be totally honest though, why this works isn't 100% clear. The
syncErrorThrowable
stuff is pretty hairy. I tried to map out whatsyncErrorThrowable
is being used for, when its set correctly, when its not, etc and noticed a pattern that errors were going down the_trySubscribe
when there was athis.source
but that always expectedsyncErrorThrowable = true
otherwise the condition right after wouldn't do the rethrowing.Mostly what's not clear is why this only happens with Subject, timer, interval, etc combined with a nested Observable via merge/concat/etc. Seemed like it might be related to the fact that these override
_subscribe
but others do too and I couldn't find a pattern otherwise.The minimum reproduction here is, somewhat strangely, the inverse of what most often the problem seems to be. I tried to also find a minimum reproduction for what I think is the issue most often found (swallowing instead of rethrowing) I couldn't. The closest I could find was this:
I'm hoping that either this is good enough or perhaps this will help someone get a more clear understanding of the problem.
Fixes #3183, #2813