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 and node v0.12 #3839

Closed
mainakae opened this issue May 13, 2015 · 8 comments
Closed

Promises and node v0.12 #3839

mainakae opened this issue May 13, 2015 · 8 comments

Comments

@mainakae
Copy link
Contributor

Hello all,

I've noticed that after upgrading my node, form 0.10.x to 0.12.2, I'm no longer able to call the "finally" method on promises returned by the api; now it throws "TypeError: undefined is not a function".

var db = new PouchDB('http:https://localhost:5984/db");

db.allDocs().then(...).finally(...); // NO LONGER WORKING!

@daleharvey
Copy link
Member

Hrm I dont think Promise.finally is in the official spec? if so it shouldnt have ever been part of our API apologies

@calvinmetcalf
Copy link
Member

right and you were never able to do this in the browser, it's because we
only use bluebird for promises if native ones are not available

On Wed, May 13, 2015 at 8:37 AM Dale Harvey [email protected]
wrote:

Hrm I dont think Promise.finally is in the official spec? if so it
shouldnt have ever been part of our API apologies


Reply to this email directly or view it on GitHub
#3839 (comment).

@daleharvey
Copy link
Member

We should either 1. Figure out how to remove finally from bluebird promises, 2. Use a spec compliant lib, 3. Only use native promises (not support older node versions)

It looks like all stable releases of node support Promises natively but not sure what the uptake for these releases are, may be harsh to drop support already

@calvinmetcalf
Copy link
Member

you can just switch to using lie only and not bluebird

On Wed, May 13, 2015 at 9:44 AM Dale Harvey [email protected]
wrote:

We should either 1. Figure out how to remove finally from bluebird
promises, 2. Use a spec compliant lib, 3. Not support node versions that
dont support native promises.

It looks like all stable releases of node support Promises natively but
not sure what the uptake for these releases are, may be harsh to drop
support already


Reply to this email directly or view it on GitHub
#3839 (comment).

@mainakae
Copy link
Contributor Author

I know it's not part of the specification, I've been trying out lately lie, q and bluebird among others, and though it's somehow arguable and prone to change in the future, seems that bluebird is the right choice. In fact I adopted it as the promises library for my latest app (in part in sake of homogeneity with PouchDB).

The issue is not so much about loosing that functionality (again: as things go by, you might be inclined to chose another lib, and then following tightly the specification will be a bonus) but about some shaky things going on under the hood, maybe worth checking.

@daleharvey
Copy link
Member

In node 0.12 Promises are natively supported, so it will start to use the native promises which dont have .finally, similiar to what happens in the browser. We have always planned to be spec compatible so we can remove any of our own Promises code when its widely enough supported.

Removing bluebird and just using lie for older node versions sounds like a good plan

@nolanlawson
Copy link
Member

I'm fine with removing bluebird and using global.Promise || require('lie'). Simplifies things a lot, although technically may justify a major version release.

@daleharvey
Copy link
Member

Fixed in 09ce6c8

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

4 participants