Skip to content

Error: A value was yielded that could not be treated as a promise

benjamingr edited this page Dec 21, 2014 · 2 revisions

Error: A value was yielded that could not be treated as a promise

You are getting this error because you have tried to yield something in a coroutine without a yield handler, for example:

var coroutine = Promise.coroutine(function*(){
    var bar = yield "Foo";
    console.log(bar);
});

The solution is to either convert it to a promise by calling Promise.resolve on it or Promise.promisify if it's a callback:

var coroutine = Promise.coroutine(function*(){
    var bar = yield Promise.resolve("Foo");
    console.log(bar);
});

Or to use .addYieldHandler to teach Promise.coroutine to accept these sort of values.