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

Use native polyfill on Chrome and Node.js v0.12 #111

Closed
piranna opened this issue Apr 21, 2015 · 15 comments
Closed

Use native polyfill on Chrome and Node.js v0.12 #111

piranna opened this issue Apr 21, 2015 · 15 comments

Comments

@piranna
Copy link

piranna commented Apr 21, 2015

On v8 based Javascript engines, the check for using the native Polyfill implementations fails because the check

Object.prototype.toString.call(P.resolve())

return [object Object] instead of the expected [object Promise], that only happens to be on Firefox. I think this check should be less strict or use other condition so v8 native Promises can be used.

@yethee
Copy link

yethee commented Apr 21, 2015

And not has the static method cast.

@piranna
Copy link
Author

piranna commented Apr 21, 2015

And not has the static method cast.

No they don't have it (at least Chromium 41 and Node.js v0.12.2)

@yethee
Copy link

yethee commented Apr 21, 2015

I mean that the native Promise of V8 has no method cast.

@piranna
Copy link
Author

piranna commented Apr 21, 2015

Firefox 37 doesn't have it either...

@lvscar
Copy link

lvscar commented Apr 22, 2015

#99 fixed it , but not have merged .

@piranna
Copy link
Author

piranna commented Apr 22, 2015

Definitely a better checker, let's see if it got merged :-)
El 22/04/2015 04:39, "lvs(zikuan.ly)" notifications@github.com escribió:

#99 #99 fixed it , but
not have merged .


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

@klimashkin
Copy link

Object.prototype.toString.call(Promise.resolve())
"[object Object]"

Chrome 45.0.2428.0 Canary
V8 4.5.45

Such method seems like suits better:

typeof Promise !== "undefined" && Promise.toString().indexOf("[native code]") > -1

http://stackoverflow.com/posts/22517133/revisions

@stefanpenner
Copy link
Owner

There are still some serious bugs in the v8 promise implementation. Some timing and extra side effects. So we are luckily that the current check still fails. Hopefully they fix the other issues before they fix the toString

@klimashkin
Copy link

Could you give an examples of v8 bugs?

@stefanpenner
Copy link
Owner

It doesn't handle inheritance correctly And resolve isn't correct. Which results in observable ordering differences https://code.google.com/p/v8/issues/detail?id=4162&q=Promise&colspec=ID%20Type%20Status%20Priority%20Owner%20Summary%20HW%20OS%20Area%20Stars

@stefanpenner
Copy link
Owner

For some reason I can't find the inheritance issue I reported... Strange I have clear memory of it being responded to as well..

@stefanpenner
Copy link
Owner

@koba04
Copy link

koba04 commented Jun 11, 2015

I think it would be better to check to be 'thenable' like below.

typeof Promise === 'function' && typeof new Promise(function() {}).then === 'function'

@stefanpenner
Copy link
Owner

I think it would be better to check to be 'thenable' like below.

but the promise implementations that don't match ^^ have bugs still. Why loosen the constraint, and introduce bugs...

@NoelAbrahams
Copy link

@stefanpenner,

I see the point about the couple of bugs in Chrome's implementation. However, they may well fix the [object Promise] bug before fixing those. Then people will start defaulting to the native implementation without their knowledge.

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

7 participants