Skip to content

Conversation

akarnokd
Copy link
Collaborator

When FirstAsync finds an item, it disposes the upstream, however, the upstream may still emit an OnCompleted if it is unable to detect this dispose call (or ignores it). In this case, the FirstAsync's OnCompleted gets invoked which creates an exception that gets thrown away as the base observer is already the no-op observer, wasting resources creating the stacktrace in the process. Both plain and predicated versions are affected.

I don't know how to verify this via unit test, but this extra call can be seen when placing a breakpoint in FirstAsync's OnCompleted method and running this flow:

Observable.Return(1).FirstAsync().Subscribe();

@danielcweber danielcweber merged commit 82bfa7d into dotnet:master Jun 28, 2018
@akarnokd akarnokd deleted the FirstAsyncImprovement branch June 28, 2018 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants