From dbc651678b64f2dad3522837b865692a7ab4a4fc Mon Sep 17 00:00:00 2001 From: Alex Li Date: Sun, 14 Apr 2024 16:35:45 +0800 Subject: [PATCH] =?UTF-8?q?=E2=8F=AA=EF=B8=8F=20Not=20imply=20future=20for?= =?UTF-8?q?=20throwable=20timeout=20callback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dio/lib/src/adapters/io_adapter.dart | 8 ++++---- plugins/http2_adapter/lib/src/http2_adapter.dart | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dio/lib/src/adapters/io_adapter.dart b/dio/lib/src/adapters/io_adapter.dart index bffb07c6a..e7fd5de70 100644 --- a/dio/lib/src/adapters/io_adapter.dart +++ b/dio/lib/src/adapters/io_adapter.dart @@ -93,7 +93,7 @@ class IOHttpClientAdapter implements HttpClientAdapter { if (connectionTimeout != null && connectionTimeout > Duration.zero) { request = await reqFuture.timeout( connectionTimeout, - onTimeout: () async { + onTimeout: () { throw DioException.connectionTimeout( requestOptions: options, timeout: connectionTimeout, @@ -147,12 +147,12 @@ class IOHttpClientAdapter implements HttpClientAdapter { if (requestStream != null) { // Transform the request data. - Future future = request.addStream(requestStream); + Future future = request.addStream(requestStream); final sendTimeout = options.sendTimeout; if (sendTimeout != null && sendTimeout > Duration.zero) { future = future.timeout( sendTimeout, - onTimeout: () async { + onTimeout: () { request.abort(); throw DioException.sendTimeout( timeout: sendTimeout, @@ -169,7 +169,7 @@ class IOHttpClientAdapter implements HttpClientAdapter { if (receiveTimeout > Duration.zero) { future = future.timeout( receiveTimeout, - onTimeout: () async { + onTimeout: () { request.abort(); throw DioException.receiveTimeout( timeout: receiveTimeout, diff --git a/plugins/http2_adapter/lib/src/http2_adapter.dart b/plugins/http2_adapter/lib/src/http2_adapter.dart index ae61eb8ca..ed6e8fa63 100644 --- a/plugins/http2_adapter/lib/src/http2_adapter.dart +++ b/plugins/http2_adapter/lib/src/http2_adapter.dart @@ -137,14 +137,14 @@ class Http2Adapter implements HttpClientAdapter { } if (hasRequestData) { - Future requestStreamFuture = requestStream!.listen((data) { + Future requestStreamFuture = requestStream!.listen((data) { stream.outgoingMessages.add(DataStreamMessage(data)); }).asFuture(); final sendTimeout = options.sendTimeout ?? Duration.zero; if (sendTimeout > Duration.zero) { requestStreamFuture = requestStreamFuture.timeout( sendTimeout, - onTimeout: () async { + onTimeout: () { stream.outgoingMessages.close().catchError((_) {}); throw DioException.sendTimeout( timeout: sendTimeout,