-
Notifications
You must be signed in to change notification settings - Fork 88
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
Adds Response Time out Error to RN SDKs #721
Conversation
packages/@magic-sdk/react-native-bare/src/react-native-webview-controller.tsx
Outdated
Show resolved
Hide resolved
const timeout = setTimeout(() => { | ||
this.messageTimeouts.delete(messageId); | ||
throw createResponseTimeoutError(`Response timed out for method: ${methodType} with message id: ${messageId}`); | ||
}, 5000); // 5-second timeout |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 π€
There was a problem hiding this comment.
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}`); |
There was a problem hiding this comment.
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.
adb52d2
to
61f1514
Compare
61f1514
to
8bafb75
Compare
π¦ Pull Request
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.]
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: