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

Fix Promise.finally Non-standard behavior #293

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

liuqiang1357
Copy link

@liuqiang1357 liuqiang1357 commented Jun 7, 2018

@facebook-github-bot
Copy link

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 cla@fb.com. Thanks!

@facebook-github-bot
Copy link

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

@labs-dlugo
Copy link

How come this isn't merged yet.

@zpao
Copy link
Member

zpao commented Sep 28, 2018

@hramos - this was legit for RN. See #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.

@hramos
Copy link

hramos commented Sep 28, 2018

@yungsters ^

@yungsters
Copy link
Contributor

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

throw reason;
})
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIWI: We can replace this whole definition with just a call to require('promise/setimmediate/finally'). https://github.com/then/promise/blob/7.3.1/src/finally.js

What you have is virtually identical, just reducing the amount of code we need to have written ourselves.

@zpao
Copy link
Member

zpao commented Oct 1, 2018

@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.

@yungsters
Copy link
Contributor

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

@zpao
Copy link
Member

zpao commented Oct 2, 2018

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.

@indexzero
Copy link

@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

@grabbou
Copy link

grabbou commented Mar 19, 2019

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

facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Mar 28, 2019
Summary: See facebook/fbjs#293 for an explanation.

Reviewed By: yungsters

Differential Revision: D14658680

fbshipit-source-id: aad8808b8514817314bf67b9a43b01d52e850e36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants