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 that never completes [SDK-3216] #464

Merged
merged 2 commits into from
Mar 18, 2022
Merged

Conversation

Widcket
Copy link
Contributor

@Widcket Widcket commented Mar 18, 2022

Changes

When using Web Auth, after the native code calls the RN callback with an error or the redirect URL, the javascript code checks those values and either rejects or resolves a promise. But the code was not handling the case when both error and redirect URL are null, which can happen on iOS under particular circumstances (e.g. retrying the Web Auth login immediately after it failed).

This PR handles that case by rejecting the promise with an error.

References

Fixes #460

Testing

A unit test was added for this scenario, and also it was tested manually on iOS 15.4 (iPhone simulator), using React Native 0.66.4.

  • This change adds unit test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

@Widcket Widcket requested a review from a team as a code owner March 18, 2022 01:11
@@ -105,6 +105,20 @@ describe('Agent', () => {
A0Auth0.error = new Error('failed to load');
await expect(agent.show('https://auth0.com')).rejects.toMatchSnapshot();
});

it('should reject with error when both error and redirectURL are missing', async () => {
NativeModules.A0Auth0.showUrl = (...args) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@poovamraj poovamraj left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@Widcket Widcket merged commit 891e5b1 into master Mar 18, 2022
@Widcket Widcket deleted the fix/pending-promise branch March 18, 2022 11:10
@Widcket Widcket mentioned this pull request Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On iOS the promise returned by webauth.authorize can sometimes never complete.
2 participants