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

Adapters are not called with promises, are they? #65

Open
bergus opened this issue Jul 31, 2014 · 4 comments
Open

Adapters are not called with promises, are they? #65

bergus opened this issue Jul 31, 2014 · 4 comments
Labels

Comments

@bergus
Copy link

bergus commented Jul 31, 2014

The adapters section of the readme says:

Note that the tests will never pass a promise or a thenable as a resolution. That means that we never use the promise- or thenable-accepting forms of the resolve operation directly, and instead only use the direct fulfillment operation, since fulfill and resolve are equivalent when not given a thenable.

I'm not sure whether this is wrong, outdated or uses outdated terminology after #39 ?

The implementation that I'm currently testing does not (yet?) have a Promise constructor with a resolve callback, it only offers a fulfill callback which accepts any value and does not [[resolve]] its arguments recursively (yes, I'm allowing algebraic nesting of promises). I also did pass the monadic Promise.of for adapter.resolve.

However, this has bitten me heavily, and it took me some time to figure out that deferred.resolve is indeed called a few times with one of my Promises. Is this a bug in the test cases? An error in the documentation? Or did I just misunderstand that sentence?

@domenic
Copy link
Member

domenic commented Aug 1, 2014

It sounds like a bug in the test cases, hmm. What tests in particular trigger this?

Note that we do pass promises to deferred.reject.

@bergus
Copy link
Author

bergus commented Aug 2, 2014

What tests in particular trigger this?

The 2.3.3 testcase for

2.3.3.3: If `then` is a function, call it with `x` as `this`, first argument `resolvePromise`, and second argument `rejectPromise`
2.3.3.3.1: If/when `resolvePromise` is called with value `y`, run `[[Resolve]](promise, y)`
`y` is a thenable for a thenable
[…]

with its various y is a promise for … combinations. From my counts, a complete run will call both adapter.resolved and deferred.resolve 56 times each.

Note that we do pass promises to deferred.reject

That's OK, the spec expects nesting behaviour for that anyway :-)

@domenic domenic added the bug label Sep 19, 2014
@hbarcelos
Copy link

+1 on this. I'm facing the same problem.

@andot
Copy link

andot commented Feb 20, 2016

Promises/A+ Tests
2.3.3: Otherwise, if `x` is an object or function,
2.3.3.3: If `then` is a function, call it with `x` as `this`, first argument `resolvePromise`, and second argument `rejectPromise`
2.3.3.3.1: If/when `resolvePromise` is called with value `y`, run `[[Resolve]](promise, y)`
`y` is a thenable for a thenable
`y` is an asynchronously-fulfilled custom thenable for a thenable that fulfills but then throws
`then` calls `resolvePromise` synchronously
via return from a fulfilled promise
                        Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at onPromiseFulfilled (promiseTest.js:2871:13)
   ...

https://saucelabs.com/jobs/7065f290c8aa403fb50c0f677d98b9e9

I meet the same problem on android 4.4 default browser. but other browsers all pass.

https://github.com/hprose/hprose-js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants