Merge pull request #1650 from famedly/krille/fix-10-second-timeout-initial-sync
fix: Increase timeout for initial sync from 10 seconds to 2 minutes
This commit is contained in:
commit
26c1629e7e
|
|
@ -1695,7 +1695,12 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
Object? syncError;
|
Object? syncError;
|
||||||
await _checkSyncFilter();
|
await _checkSyncFilter();
|
||||||
|
|
||||||
|
// The timeout we send to the server for the sync loop. It says to the
|
||||||
|
// server that we want to receive an empty sync response after this
|
||||||
|
// amount of time if nothing happens.
|
||||||
timeout ??= const Duration(seconds: 30);
|
timeout ??= const Duration(seconds: 30);
|
||||||
|
|
||||||
final syncRequest = sync(
|
final syncRequest = sync(
|
||||||
filter: syncFilterId,
|
filter: syncFilterId,
|
||||||
since: prevBatch,
|
since: prevBatch,
|
||||||
|
|
@ -1711,8 +1716,15 @@ class Client extends MatrixApi {
|
||||||
});
|
});
|
||||||
_currentSyncId = syncRequest.hashCode;
|
_currentSyncId = syncRequest.hashCode;
|
||||||
onSyncStatus.add(SyncStatusUpdate(SyncStatus.waitingForResponse));
|
onSyncStatus.add(SyncStatusUpdate(SyncStatus.waitingForResponse));
|
||||||
final syncResp =
|
|
||||||
await syncRequest.timeout(timeout + const Duration(seconds: 10));
|
// The timeout for the response from the server. If we do not set a sync
|
||||||
|
// timeout (for initial sync) we give the server a longer time to
|
||||||
|
// responde.
|
||||||
|
final responseTimeout = timeout == Duration.zero
|
||||||
|
? const Duration(minutes: 2)
|
||||||
|
: timeout + const Duration(seconds: 10);
|
||||||
|
|
||||||
|
final syncResp = await syncRequest.timeout(responseTimeout);
|
||||||
onSyncStatus.add(SyncStatusUpdate(SyncStatus.processing));
|
onSyncStatus.add(SyncStatusUpdate(SyncStatus.processing));
|
||||||
if (syncResp == null) throw syncError ?? 'Unknown sync error';
|
if (syncResp == null) throw syncError ?? 'Unknown sync error';
|
||||||
if (_currentSyncId != syncRequest.hashCode) {
|
if (_currentSyncId != syncRequest.hashCode) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue