From 5b7317ba89166f3cf1af98cb280a4cc8e78f25f9 Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Tue, 23 Mar 2021 00:11:36 +0100 Subject: [PATCH] Force close the http-client on IOAnalytics.close() (#155) force close the http-client on IOAnalytics.close() --- CHANGELOG.md | 4 ++++ lib/src/usage_impl_io.dart | 6 +++++- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de81b95..408a819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.0.1 +- Force close the http client from `IOAnalytics.close()`. + This prevents lingering requests from making the application hang. + ## 4.0.0 - Publishing a null safe stable release. diff --git a/lib/src/usage_impl_io.dart b/lib/src/usage_impl_io.dart index 62388ad..c692f6a 100644 --- a/lib/src/usage_impl_io.dart +++ b/lib/src/usage_impl_io.dart @@ -102,7 +102,11 @@ class IOPostHandler extends PostHandler { } @override - void close() => _client?.close(); + void close() { + // Do a force close to ensure that lingering requests will not stall the + // program. + _client?.close(force: true); + } } JsonEncoder _jsonEncoder = JsonEncoder.withIndent(' '); diff --git a/pubspec.yaml b/pubspec.yaml index 42b2e18..36738fd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: usage -version: 4.0.0 +version: 4.0.1 description: A Google Analytics wrapper for command-line, web, and Flutter apps. homepage: https://github.com/dart-lang/usage