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

Adds Response Time out Error to RN SDKs #721

Merged
merged 16 commits into from
Mar 9, 2024

Conversation

Ariflo
Copy link
Contributor

@Ariflo Ariflo commented Mar 1, 2024

πŸ“¦ Pull Request

Screenshot 2024-03-04 at 11 30 19β€―AM

Adds a Response Timeout Error to our RN SDKs. See PDEEXP-233 for details.

βœ… Fixed Issues

n/a

🚨 Test instructions

[Describe any additional context required to test the PR/feature/bug fix.]

⚠️ Don't forget to add a semver label!

Please 🚨 ONLY ADD ONE 🚨 of the following labels, failing to do so may lead to adverse versioning of your changes when published:

  • patch: Bug Fix?
  • minor: New Feature?
  • major: Breaking Change?
  • skip-release: It's unnecessary to publish this change.

Special Note

Please avoid adding any of the Priority labels as they conflict with the labels above ☝️

πŸ“¦ Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-ext/[email protected]
npm install @magic-sdk/[email protected]
npm install @magic-sdk/[email protected]
npm install @magic-sdk/[email protected]
npm install @magic-sdk/[email protected]
npm install @magic-sdk/[email protected]
npm install @magic-sdk/[email protected]
npm install [email protected]
# or 
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-ext/[email protected]
yarn add @magic-sdk/[email protected]
yarn add @magic-sdk/[email protected]
yarn add @magic-sdk/[email protected]
yarn add @magic-sdk/[email protected]
yarn add @magic-sdk/[email protected]
yarn add @magic-sdk/[email protected]
yarn add [email protected]

@Ariflo Ariflo added the minor Increment the minor version when merged label Mar 1, 2024
@Ariflo Ariflo self-assigned this Mar 1, 2024
am-hernandez
am-hernandez previously approved these changes Mar 1, 2024
const timeout = setTimeout(() => {
this.messageTimeouts.delete(messageId);
throw createResponseTimeoutError(`Response timed out for method: ${methodType} with message id: ${messageId}`);
}, 5000); // 5-second timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure 5s is enough? We've had reports of calls to certain methods taking longer than 5s in regions like Asia and South Asia.

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, do we know why the calls never return in some cases? I agree with having a time limit but if there's an issue on phantom that causes responses to hang we should probably look into that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@romin-halltari in this case, there could be multiple reasons for the delay. For the scope of this PR, the developer wants some indication that a response has been delayed, so we're focusing on just indicating that a delay has occurred as opposed to resolving any particular delay.

As for the 5 seconds, that was a random choice on my part. Given the realities of our users in Asia and South Asia I'll up it to 10 seconds. Thanks for the pointing that out!

@@ -139,6 +140,18 @@ export class ReactNativeWebViewController extends ViewController {
}, [show]);

const handleWebViewMessage = useCallback((event: any) => {
const data = JSON.parse(event.nativeEvent.data);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is event.nativeEvent.data always defined? Because otherwise it would result in a crash, and that event: any typing above is not very reassuring πŸ€”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not, hence the if-conditional check below πŸ€”

// Setup timeout for message response
const timeout = setTimeout(() => {
this.messageTimeouts.delete(messageId);
throw createResponseTimeoutError(`Response timed out for method: ${methodType} with message id: ${messageId}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd prefer we pass methodType and messageId as arguments to createResponseTimeoutError and create the error message inside that function, as it sounds like it would be the same everywhere.

@Ariflo Ariflo force-pushed the ariflo-PDEEXP-233-add-response-timeout-to-RN-SDKs branch from adb52d2 to 61f1514 Compare March 4, 2024 23:40
@Ariflo Ariflo force-pushed the ariflo-PDEEXP-233-add-response-timeout-to-RN-SDKs branch from 61f1514 to 8bafb75 Compare March 5, 2024 00:03
@am-hernandez am-hernandez self-requested a review March 9, 2024 01:36
@Ariflo Ariflo added this pull request to the merge queue Mar 9, 2024
Merged via the queue into master with commit 290230a Mar 9, 2024
4 checks passed
@Ariflo Ariflo deleted the ariflo-PDEEXP-233-add-response-timeout-to-RN-SDKs branch March 9, 2024 01:46
@Ariflo Ariflo added the released This issue/pull request has been released. label Mar 9, 2024
@magiclabs magiclabs deleted a comment from Ariflo Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants