-
Notifications
You must be signed in to change notification settings - Fork 5
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
Problem: walletconnnect requests would not be cleared if no response (fix #302) #303
Problem: walletconnnect requests would not be cleared if no response (fix #302) #303
Conversation
Unreal test logs:
|
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.
I haven't read the original code in a while and feel a bit sick today. the patch looks ok, but can't confirm for 100%
Codecov Report
@@ Coverage Diff @@
## main #303 +/- ##
==========================================
- Coverage 25.59% 25.27% -0.33%
==========================================
Files 20 20
Lines 2188 2216 +28
==========================================
Hits 560 560
- Misses 1628 1656 +28
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
It is hardcoded as 1 minute. What operations could be 10 minutes? |
The clear thread would not stop, if succeeded, pending_requests would be removed on the normal thread, while on the clear thread, calling |
ok |
instead sleep, |
because, it waits let's say 1 minute sleep, |
It is a different purpose. This PR is about cleaning up the pending request no matter it is valid or not, after timeout, to handle no response case (thread may never end if we only query it and wait it to end). |
Spawning would not be too many, it has |
socket sender is changed to bounded, but it can cause waiting , if there are multiple requests. |
and
if signing is done fast, how this async finishes? |
Bound is enough, and more performant, bounded buffer size is defined by pending_requests_limit. As only 2 requests |
yes, if called , 3 times, 3rd connect will keep waiting until it can send. and socket.rs 258 line
this will be alive , no matter succeed or not, for pending_requests_timeout time so this can cause dead-lock in application side. |
It will still run, after timeout, it would return None. Since the corresponding request of that id is already removed, please check https://github.com/cronos-labs/play-cpp-sdk/blob/main/wallet-connect/src/client/socket.rs#L54 |
yes, it's already removed at the stage. |
Let me check if close the timeout thread if got response. |
ok, i'll read more. |
This would not happen. Since https://github.com/cronos-labs/play-cpp-sdk/pull/303/files#diff-0fb0fbb1ca52eaa6fa7aa5c4b0958e9b85d6907737ac1fd25c1e48ce90205691R126 already limit it to at most 2. Please see the example and verify. Besides, deadlock would not happen since no mutex is used here. |
I agree with this, the timeout thread should be closed if got response. Let me do this. |
fix (cronos-labs#302) Close: - cronos-labs#302 Solution: - Add pending_requests_timeout and pending_requests_limit - Use channel instead of unbounded_channel to improve performance
fc848e1
to
94b8593
Compare
https://github.com/cronos-labs/play-cpp-sdk/blob/main/wallet-connect/src/client/socket.rs#L182 Or we could make the timeout long, long enough to let the user finish the first connection? Or make a new QR expired timeout for user to configure? |
maybe easiest not to timeout? one can still try to recreate/restart if it fails? |
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.
quite simple and nice with the timeout... just a nit that duration could just be stored in the struct directly
make 60000 as definition |
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.
lgtm
i think current approach is simplest |
Close:
Solution:
👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻
PR Checklist:
cargo build
)cargo test
)cargo fmt -- --check --color=auto
)cargo clippy
)cargo audit
)Thank you for your code, it's appreciated! :)