-
Notifications
You must be signed in to change notification settings - Fork 147
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
Chained otherwise never ends #104
Conversation
Ok, a minimal test case is that any stream that does a redirect can't be var σ = require('./lib');
var xs = σ(function(push, next) {
next(σ([1, 2, 3]));
});
xs.otherwise(σ([])).toArray(σ.log); You'd expect |
@quarterto thanks for reporting. I can confirm I'm seeing this behaviour. |
I think what's happening here is that the second redirect that's done by Something like this: diff --git a/lib/index.js b/lib/index.js
index c5060f1..379e8b6 100755
--- a/lib/index.js
+++ b/lib/index.js
@@ -371,6 +371,7 @@ function Stream(/*optional*/xs, /*optional*/ee, /*optional*/mappingHint) {
this._observers = [];
this._destructors = [];
this._send_events = false;
+ this._delegate = null;
this.source = null;
// Old-style node Stream.pipe() checks for this
@@ -847,6 +848,10 @@ Stream.prototype._redirect = function (to) {
// coerce to Stream
to = _(to);
+ while (to._delegate) {
+ to = to._delegate;
+ }
+
to._consumers = this._consumers.map(function (c) {
c.source = to;
return c;
@@ -866,6 +871,8 @@ Stream.prototype._redirect = function (to) {
this.pause();
to._checkBackPressure();
}
+
+ this._delegate = to;
};
/** |
@vqvu your patch passes the tests, want me to commit it, or you wanna start a new pull request? |
Feel free to incorporate it into your pull request.
|
Tests fail on Node 0.11 but it's not related to this pull request. |
Wow, great work you two, not an easy one to spot ;) 🍻 |
When you chain 3 or more
.otherwise
s, i.e.σ.otherwise(ρ).otherwise(τ)
, andρ
is the only nonempty stream, the resulting stream doesn't ever send any data.This pull request so far just adds a failing test, I'm having a look at fixing it.