-
Notifications
You must be signed in to change notification settings - Fork 334
refactor: Add read_timeout
for HTTP requests, make timeout
optional
#5437
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
Conversation
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 think this has one small problem.
The rest looks fine.
crates/matrix-sdk/src/client/mod.rs
Outdated
let mut request_config = self.request_config(); | ||
if let Some(timeout) = sync_settings.timeout { | ||
request_config.timeout += timeout; | ||
request_config.timeout = Some(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.
This is not quite the same. If we set the poll timeout of the sync to 30 seconds and the timeout itself was 30, then we would have had 60 here.
Instead now the connection aborts right when the poll timeout expires. I think this potentially breaks syncs for everybody.
You'll have to unwrap_or_default()
the timeout here.
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.
Oh, true. For some reason I didn't realise what this was doing was just adding the 2 durations.
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #5437 +/- ##
==========================================
- Coverage 88.86% 88.85% -0.01%
==========================================
Files 333 333
Lines 91452 91470 +18
Branches 91452 91470 +18
==========================================
+ Hits 81270 81277 +7
- Misses 6360 6369 +9
- Partials 3822 3824 +2 ☔ View full report in Codecov by Sentry. |
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.
Sorry, I think we need a better default yet 😅
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.
Looks good.
Would you like to get rid of the fixup commit or should I just squash everything? |
Also, would you like to mention this as a bugfix in the changelog? Might make sense to mention this. |
This allows us to remove the default timeout on a per-request basis
…ions that have been stale for longer than the specified timeout
…`read_timeout` instead Users with poor network connectivity complained their downloads were cancelled for no good reason after 30s before (the default `timeout` value).
d8ecab0
to
ac10d4a
Compare
I've already added a changelog entry and squashed the fixup 👍 . |
Would this apply to sync too? I ask because if you've ever tried to use EX on an airplane, you'd understand what "unusable network" means 😂 Sync is also affected by this too in extreme cases |
For |
You mean that 30 seconds isn't enough to get a sync response? This Though the In other words we'd like: seanmonstar/reqwest#2764. |
In my experience, no. Provided the |
Well that would explain why it doesn't work for you, if the request doesn't finish we abort after 30 seconds no matter if there's still data coming in. The We should probably migrate away from |
Yeah that sounds like a good improvement! It would certainly fix/prevent element-hq/element-x-android#1841 in the future |
Having the
read_timeout
value set allows us to have long network requests that will get cancelled automatically when no data is received for a certain amount of time.If we combine it with being able to remove the existing default
timeout
value for some requests, it would fix the issue with downloading large files in poor network connectivity scenarios where the download would just cancel automatically after the timeout (30s) was reached.Signed-off-by: