Skip to content

Commit 431da8c

Browse files
fix: Close HttpClient in StreamingDataSource.stop() to prevent resource leak
- Add close() method to HttpClient class that closes underlying http.Client - Call _pollingClient.close() in StreamingDataSource.stop() method - Fixes dart analyzer error about unclosed HttpClient resource Addresses Bugbot finding about resource leak. Co-Authored-By: [email protected] <[email protected]>
1 parent e4f6c20 commit 431da8c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

packages/common/lib/src/network/http_client.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,9 @@ final class HttpClient {
8282
return await http.Response.fromStream(streamedResponse)
8383
.timeout(_httpProperties.readTimeout);
8484
}
85+
86+
/// Close the underlying HTTP client and free its resources.
87+
void close() {
88+
_client.close();
89+
}
8590
}

packages/common_client/lib/src/data_sources/streaming_data_source.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ final class StreamingDataSource implements DataSource {
160160
_stopped = true;
161161
_pollGeneration++;
162162
_pollActiveSince = null;
163+
_pollingClient.close();
163164
_dataController.close();
164165
}
165166

0 commit comments

Comments
 (0)