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

Promises that return values now error on finished #700

Closed
corbinu opened this issue May 1, 2017 · 4 comments
Assignees
Labels
bug
Milestone

Comments

@corbinu
Copy link
Contributor

@corbinu corbinu commented May 1, 2017

The latest change in 13.0.3 has caused tests that return a promise that returns an value to cause an error. Looks like it was working from 10.1.0 on.

 Non Error object received or caught

      at Immediate.finish (/home/corbinu/project/node_modules/lab/lib/runner.js:646:19)
      at runCallback (timers.js:676:20)
      at tryOnImmediate (timers.js:645:5)
      at processImmediate [as _immediateCallback] (timers.js:617:5)

for example a test

function getVals() {
    return new Promise((resolve) => {
        resolve([1, 2, 3]);
    });
}

lab.test("Returns value", () => {

    return getVals().then((vals) => {
        expect(vals).to.be.an.array();

        return vals;
    });

});
@Marsup

This comment has been minimized.

Copy link
Member

@Marsup Marsup commented May 1, 2017

Indeed, my bad. At least now we have a test for it :)

@corbinu

This comment has been minimized.

Copy link
Contributor Author

@corbinu corbinu commented May 1, 2017

No worries happy to help :)

@geek geek added this to the 13.0.4 milestone May 1, 2017
@geek geek self-assigned this May 1, 2017
@geek geek closed this May 1, 2017
@geek

This comment has been minimized.

Copy link
Member

@geek geek commented May 1, 2017

@corbinu thanks for the help, this is now released as v13.0.4

@jcollum

This comment has been minimized.

Copy link

@jcollum jcollum commented Oct 18, 2017

This will also happen if you add done to a promise chain:

 Promise.mapSeries( //bluebird 
          [
            ... many promises
          ],
          () => {} //iterator, don't care about iteration here 
        )
          .then(done) // oops, done is called with the results of the mapSeries call!! 
          .catch(err => {
            console.error(err);
            done(err);
          });
      });

Solution:

 .then(() => done() )

That error is mighty cryptic though. Could it be changed to "done called with non-Error object"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.