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

Wrong chain + setImmediate behavior #195

Closed
jakubmazanec opened this issue Mar 25, 2019 · 1 comment
Closed

Wrong chain + setImmediate behavior #195

jakubmazanec opened this issue Mar 25, 2019 · 1 comment

Comments

@jakubmazanec
Copy link

jakubmazanec commented Mar 25, 2019

I have the following code, taken from the test chain returns stream with result from all streams created by function:

var result = [];
function f(v) {
  var s = stream();
  setImmediate(function() {
    s(v + 1)(v + 2)(v + 3);
  });
  return s;
}
var s = stream();
flyd.map(function(v) {
  result.push(v);
}, flyd.chain(f, s));
s(1)(3)(5);
setImmediate(function() {
  console.log(); // -> [6, 7, 8]
});

According to the test, the console.log output should be [2, 3, 4, 4, 5, 6, 6, 7, 8], but I got [6, 7, 8]. I think there may be an issue with the first setImmediate, but I can't put my finger on it. Any thoughts?

@nordfjord
Copy link
Collaborator

Thank you for raising this.

The test should be failing.

but because this happens asynchronously and I omitted the done callback the exception is thrown after the test is marked green so it's not raised.

I'll submit a PR to fix this.

It will involve changing things slightly as it's expected behaviour based on the code that we only get 6, 7, 8

nordfjord pushed a commit that referenced this issue Mar 29, 2019
The issue came about because the test is asynchronous but wasn't
supplied a done callback.

This lead to a swallowed error.

This commit fixes the test such that it gives the expected result and
calls the done callback
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

No branches or pull requests

2 participants