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

has a bluebird waring when NODE_ENV=development #29

Closed
coudly opened this issue Nov 30, 2015 · 4 comments
Closed

has a bluebird waring when NODE_ENV=development #29

coudly opened this issue Nov 30, 2015 · 4 comments

Comments

@coudly
Copy link

coudly commented Nov 30, 2015

test.js

'use strict';

var async = require('asyncawait/async');
var await = require('asyncawait/await');
var Promise = require('bluebird');

var fs = require("fs");

function existsAsync(path) {
    return new Promise(function (resolve) {
        fs.exists(path, resolve);
    });
}

var doneAsync = async (function(file1, file2){
    var afound = await ( existsAsync(file1) );
    if (!afound) {
        console.log('doneAsync vm notfound : %s', file1);
        return false;
    }
    var bfound= await ( existsAsync(file2) );
    if (!bfound) {
        console.log('doneAsync notfound : %s', file2);
        return false;
    }
    return true;
});

doneAsync('package.json', 'test.js').then(function(existsAll) {
    console.log(existsAll)
})

console like below

D:\>set NODE_ENV=development

D:\>node test.js
Warning: a promise was created in a  handler but was not returned from it
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at existsAsync (D:\test.js:10:12)
    at D:\test.js:21:24
From previous event:
    at await (D:\node_modules\asyncawait\src\await\makeAwaitFunc.js:37:18)
    at D:\test.js:16:18
    at tryBlock (D:\node_modules\asyncawait\src\async\fiberManager.js:39:33)
    at runInFiber (D:\node_modules\asyncawait\src\async\fiberManager.js:26:9)

true

I think fixed like this
https://github.com/yortus/asyncawait/blob/master/src/await/makeAwaitFunc.ts#L48

        var fiber = Fiber.current;
        if (expr && _.isFunction(expr.then)) {

            // A promise: resume the coroutine with the resolved value, or throw the rejection value into it.
            //expr.then(val => { fiber.run(val); fiber = null; }, err => { fiber.throwInto(err); fiber = null; });
            //fixed > not warning
            expr.then(val => { fiber.run(val); fiber = null; return val; }, err => { fiber.throwInto(err); fiber = null; });
        }
@yortus
Copy link
Owner

yortus commented Nov 30, 2015

Hi @coudly,

I can't reproduce the error. I'm using the exact code above, both with and without set NODE_ENV=development.

What bluebird version are you using?

@tskomudek
Copy link

Having the same issue with bluebird version 3.1.1.

Hope this helps ;)

@yortus yortus closed this as completed in 250cba2 Jan 5, 2016
@yortus
Copy link
Owner

yortus commented Jan 5, 2016

Thanks @tskomudek for the bluebird info - I see they have added this new warning in 3.x.

It's a bit annoying since there's nothing wrong with the handlers as they were, but they had to be modified to suppress the bluebird 3.x warning. Thanks @coudly for pinpointing where the changes were needed.

@coudly or @tskomudek can you verify this is fixed for you in v1.0.2?

@tskomudek
Copy link

Hi yortus,
yes i can confirm this to be fixed in 1.0.2.
Great library, thanks a lot.

yortus added a commit that referenced this issue Feb 10, 2016
this got overlooked in previous fix.
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

3 participants