fbjs icon indicating copy to clipboard operation
fbjs copied to clipboard

Fix Promise.finally Non-standard behavior

Open liuqiang1357 opened this issue 7 years ago • 11 comments

Standard behavior: Promise.prototype.finally()

Related issue: react-native#17972, react-native#19490, fbjs#132

liuqiang1357 avatar Jun 07 '18 14:06 liuqiang1357

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

facebook-github-bot avatar Jun 07 '18 14:06 facebook-github-bot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

facebook-github-bot avatar Jun 10 '18 19:06 facebook-github-bot

How come this isn't merged yet.

labs-dlugo avatar Aug 31 '18 16:08 labs-dlugo

@hramos - this was legit for RN. See https://github.com/facebook/fbjs/pull/95. If it's not longer needed, can you confirm? We can ship a new fbjs 0.8.x release so RN doesn't have to update to the newer releases.

zpao avatar Sep 28 '18 18:09 zpao

@yungsters ^

hramos avatar Sep 28 '18 22:09 hramos

@zpao, React Native still uses Promise.native.js. Thoughts on how to migrate to the specification-compliant implementation?

yungsters avatar Sep 29 '18 00:09 yungsters

@yungsters Does RN's runtime not have a native Promise impl yet? Feels like we should do that, then swap this module out for something that just returns the existing global.

zpao avatar Oct 01 '18 23:10 zpao

React Native's version of JSC on Android is super old. On iOS, we delegate to iOS. 👎

yungsters avatar Oct 02 '18 00:10 yungsters

Ok, then this (or my recommendation) are effectively the same as the spec (minus some nuance). There's https://github.com/es-shims/Promise.prototype.finally/blob/master/implementation.js but that's looking pretty overkill, especially since we might not even have a native Promise to begin with. There are only a couple small differences between the old impl and this. Namely resolution/reject value.

Alternatively, you could ship the exact Promise polyfill you want in RN, and then the module here could just check for the global first. May lead to some duplicate packaging though since it'd be a runtime check.

As for rolling it out… obviously it could lead to behavior changes. I'd probably do an internal audit of finally() callsites and get an idea of impact.

Happy to run the release here when you're ready. RN is locked at a version so can happen on separate schedules.

zpao avatar Oct 02 '18 00:10 zpao

@zpao is there an ETA for this to land? Agree with you that logistically it's safe since RN is locked at a specific version. Colleague of mine lost a day and a half to this in RN so the struggle in the community is still real.

cc/ @hramos

indexzero avatar Dec 14 '18 20:12 indexzero

Now that JSC on Android is updated, maybe we can continue with this PR? @yungsters

grabbou avatar Mar 19 '19 13:03 grabbou