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,