Closed ioctaptceb closed 8 years ago
@ioctaptceb Did you find an answer to this? I'm seeing that none of my promises are running their then
methods in PhantomJS 2.1.1.
@tylercollier there are a few factors, but I didnt have time to fully investigate. It looks like the initial return from the promise (the one your return with resolve) is the return value used for future chained promises. If you specify a different return value from a function in .then()
, the function will be run immediately. I took a look at the code and unfortunately this isnt what (from my brief reading) should be the case, because it seems that it should return the return of the then. However I found that if you always return the resolve value of the promise, it works as expected. I didnt have time to dig in deeper so i just organized my code to always return the resolved value, so that it could be tested.
as for what you are seeing, I am not sure if it is the same, what does your code look like?
I'm so sorry, I typed the following last night but forgot to press the send button. So, there is no issue for me and this case can be closed (unless you want it open for yourself).
My problem was I wasn't calling my mocha it
block's done()
method.
given:
require('es6-promise');
function somePromise() {
return Promise.resolve('some static value');
}
function doFunction(result) {
console.log(result);
return result;
}
function doOtherFunction(result) {
console.log(result);
return result;
}
somePromise().then(doFunction).then(doOtherFunction);
and
browserify test.js -o out.js
phantomjs out.js
the output is:
some static value
some static value
This seems true for phantom 1.9.2 and 2.x.
Please runnable a reproduction, that demonstrates this issue and I can reopen.
Hi,
Was using this library to polyfill phantomjs's lack of promise implementation. However, i came across the problem that chaining multiple then's results in the following error
Setup:
the first
then
statement acts as expected.doFunction
will log 'some static value'. The secondthen
statement, however, will logundefined
.Any thoughts on why this might be happening?