@@ -1181,20 +1181,31 @@ private async Task<string> SendAsync(
11811181 HttpContent ? requestContent = null
11821182 )
11831183 {
1184- using var timeout = new CancellationTokenSource ( GetRequestTimeout ( method , relativePath ) ) ;
1184+ TimeSpan requestTimeout = GetRequestTimeout ( method , relativePath ) ;
1185+ using var timeout = new CancellationTokenSource ( requestTimeout ) ;
11851186 using var request = new HttpRequestMessage ( method , BuildRelativeUri ( relativePath , queryParameters ) ) ;
11861187 request . Content = requestContent ;
1187- using var response = await _httpClient . SendAsync ( request , timeout . Token ) ;
1188- string content = await response . Content . ReadAsStringAsync ( ) ;
1188+ try
1189+ {
1190+ using var response = await _httpClient . SendAsync ( request , timeout . Token ) ;
1191+ string content = await response . Content . ReadAsStringAsync ( timeout . Token ) ;
11891192
1190- if ( ! response . IsSuccessStatusCode )
1193+ if ( ! response . IsSuccessStatusCode )
1194+ {
1195+ throw new InvalidOperationException (
1196+ string . IsNullOrWhiteSpace ( content ) ? response . ReasonPhrase : content
1197+ ) ;
1198+ }
1199+
1200+ return content ;
1201+ }
1202+ catch ( OperationCanceledException ex ) when ( timeout . IsCancellationRequested )
11911203 {
1192- throw new InvalidOperationException (
1193- string . IsNullOrWhiteSpace ( content ) ? response . ReasonPhrase : content
1204+ throw new TimeoutException (
1205+ $ "UniGetUI did not answer { method . Method } { relativePath } within { requestTimeout . TotalSeconds : 0} seconds.",
1206+ ex
11941207 ) ;
11951208 }
1196-
1197- return content ;
11981209 }
11991210
12001211 private async Task < T ? > ReadAuthenticatedJsonAsync < T > (
@@ -1474,7 +1485,7 @@ private static TimeSpan GetRequestTimeout(HttpMethod method, string relativePath
14741485 {
14751486 return method == HttpMethod . Post
14761487 ? TimeSpan . FromMinutes ( 5 )
1477- : TimeSpan . FromSeconds ( 30 ) ;
1488+ : TimeSpan . FromMinutes ( 2 ) ;
14781489 }
14791490
14801491 if ( IpcHttpRoutes . StartsWith ( relativePath , "/bundles/install" ) )
@@ -1536,7 +1547,8 @@ private static bool IsConnectivityException(Exception exception)
15361547 return exception is HttpRequestException
15371548 or IOException
15381549 or TaskCanceledException
1539- or OperationCanceledException ;
1550+ or OperationCanceledException
1551+ or TimeoutException ;
15401552 }
15411553
15421554 private static IpcEndpointRegistration ? SelectLiveRegistration (
0 commit comments