Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/lib/backend/http/http_pool_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class HttpPoolManager {

HttpPoolManager._() {
final httpClient = HttpClient()
..maxConnectionsPerHost = 15
..maxConnectionsPerHost = 20
..idleTimeout = const Duration(seconds: 15);

_client = IOClient(httpClient);
_pool = Pool(10, timeout: const Duration(seconds: 60));
_pool = Pool(20, timeout: const Duration(seconds: 120));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While increasing the pool size is a good step towards mitigating the deadlock, there's a configuration mismatch that could lead to subtle issues.

The Pool size is being increased to 20, but the underlying HttpClient is still configured with maxConnectionsPerHost = 15 (on line 19). If all concurrent requests from the pool target the same host, the HttpClient will become the bottleneck, queuing any requests beyond the 15th. This makes the Pool's limit of 20 misleading and can complicate debugging.

For more predictable performance and clearer control over concurrency, these two limits should be aligned. I suggest setting the pool size to 15 to match maxConnectionsPerHost. This still provides a 50% increase in concurrency over the original value of 10.

If a concurrency of 20 is a hard requirement, please consider also increasing maxConnectionsPerHost to 20 in a subsequent change.

Suggested change
_pool = Pool(20, timeout: const Duration(seconds: 120));
_pool = Pool(15, timeout: const Duration(seconds: 120));

}

Future<http.Response> send(
Expand Down