Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(audit): mirror source if durations are Observable.empty() #2595

Merged
merged 2 commits into from
Jun 14, 2017
Merged

fix(audit): mirror source if durations are Observable.empty() #2595

merged 2 commits into from
Jun 14, 2017

Conversation

GrahamDennis
Copy link
Contributor

Description:
The audit operator was suppressing all events if the duration was Observable.empty() or any observable that was already complete.

There was already a similar test for this, but it relied upon cold('|'). It might be worth considering either duplicating tests involving cold('|') to use Observable.empty() or special-casing it to return Observable.empty()

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0007%) to 97.645% when pulling d10bcae on GrahamDennis:feature/fix-audit-when-duration-selector-is-empty into ebf6393 on ReactiveX:master.

@@ -86,6 +86,9 @@ class AuditSubscriber<T, R> extends OuterSubscriber<T, R> {
this.destination.error(errorObject.e);
} else {
this.add(this.throttled = subscribeToResult(this, duration));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't synchronized subscription to be added into subscription as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you mean. Can you explain?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer this one - https://github.com/ReactiveX/rxjs/pull/1490/files#diff-4c9df56dc210f37759b96afb96e5fdd0R135

if subscribeToResult is synchronously subscribed, returned subscription is immediately unsubscribed already, so there's no meaning to add subscription for managing it (this.add). So in that case, check returned subscription and add only if it's asynchronous would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR to address this.

@@ -86,6 +86,9 @@ class AuditSubscriber<T, R> extends OuterSubscriber<T, R> {
this.destination.error(errorObject.e);
} else {
this.add(this.throttled = subscribeToResult(this, duration));
if (this.throttled.closed) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about this change. Wouldn't this make it so a completed Subject would cause this behavior? That seems incorrect.

Is this really a subscription ordering thing? What do you think @trxcllnt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have assumed this change's similar to this -> #1490, where there are synchronous observables are supplied subscribeToResult completes immediately instead of scheduled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I ran this code under a debugger, that's exactly what happened: inside subscribeToResult, the observable completed, so by the time it is returned, it is already completed, so we shouldn't throttle subsequent results anymore.

I have two questions:

  1. How should we solve this problem?
  2. How do we avoid this problem elsewhere as the cold('|') observable used in tests doesn't complete immediately.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 97.736% when pulling 5aaed30 on GrahamDennis:feature/fix-audit-when-duration-selector-is-empty into ebf6393 on ReactiveX:master.

@GrahamDennis
Copy link
Contributor Author

Who can merge this?

@kwonoj
Copy link
Member

kwonoj commented May 25, 2017

I can, but checking with release cadences to make right version. Guess this is patch? /cc @benlesh

@benlesh benlesh merged commit 6ded82e into ReactiveX:master Jun 14, 2017
@deadbeef84
Copy link

There's a problem with this commit, when subscribeToResult returns null it will crash. It should check if innerSubscription is null or closed.

if (!innerSubscription || innerSubscription.closed) {

asnov added a commit to asnov/rxjs that referenced this pull request Jul 12, 2017
…ion Observable completes

Fixed the problem when subscribeToResult() returns null it will crash described by @deadbeef84.

audit() crashs with Observable.of()
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants