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

added getter for request status #681

Closed
wants to merge 2 commits into from

Conversation

Thorsson
Copy link

@Thorsson Thorsson commented Dec 5, 2023

📦 Pull Request

Adding new getter to Magic to be able to get current request status, so the app can start making requests to Magic only after it is ready. This is important when switching multiple networks and the whole view controller is reinitiated, if switching multiple times within short period it can make requests unavailable since it didn't load it all correctly. With this getter flag we know when Magic is ready to receive requests. This is already done internally and it is raising errors right now but with this approach we know to back off more correctly until it is ready.

✅ Fixed Issues

🚨 Test instructions

When you instantiate magic you have available new getter readyForRequest on magic object.

const magic = new Magic(....)

magic.readyForRequest // returns boolean if Magic can do requests
  • patch: Bug Fix?
  • minor: New Feature?

@romin-halltari
Copy link
Contributor

@Thorsson thank you for opening this PR. If you check this PR that got merged some days ago, we've removed readyForRequest. Even if it was there there though, I don't think it would solve your issue, because we were setting readyForRequest=true on the first MAGIC_OVERLAY_READY event, and it was never set back to false.

That being said, I understand your concern and I will open a ticket for us to look into it.

@Thorsson
Copy link
Author

Thorsson commented Dec 5, 2023

@romin-halltari yes it is never set back to false but when we are switching the networks the magic instance is reinitiated again, so it takes some time to be operational again for receiving requests. Since the currently used magic is stored inside global store the logic within the app is trying to check whether it is available for requests. Current implementation just returns error everytime when it is not ready

@Thorsson
Copy link
Author

Thorsson commented Dec 5, 2023

@romin-halltari I checked this PR and I saw it is now only depending on internet connection. Was this tested on slow internet connections? Because on slow connections it could take long time to initiate webview content that would be ready to accept the requests.

@romin-halltari
Copy link
Contributor

romin-halltari commented Dec 5, 2023

@Thorsson on the latest version of the library, when you make a request we wait until the the webview is ready. On the version that you were using which had readyForRequest, it would reject any request when readyForRequest is false, which causes issues with use cases such as checking if the user is logged in on app startup.

Regarding your point regarding slow internet connection, now it just means the request would take longer, but it will not be rejected immediately anymore as it was rejected on the previous version.

@Thorsson
Copy link
Author

@romin-halltari after trying newest updates on the library the original problem still exists with the linked issue. You can check with #610 and get provided example with the issue

@romin-halltari
Copy link
Contributor

@Thorsson Thank you for the heads up, I have replied on #610.

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

Successfully merging this pull request may close these issues.

None yet

2 participants