Skip to content

Commit

Permalink
⏪️ Not imply future for throwable timeout callback
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Apr 14, 2024
1 parent 6b26185 commit dbc6516
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions dio/lib/src/adapters/io_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -147,12 +147,12 @@ class IOHttpClientAdapter implements HttpClientAdapter {

if (requestStream != null) {
// Transform the request data.
Future<void> future = request.addStream(requestStream);
Future<dynamic> 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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions plugins/http2_adapter/lib/src/http2_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ class Http2Adapter implements HttpClientAdapter {
}

if (hasRequestData) {
Future<void> requestStreamFuture = requestStream!.listen((data) {
Future<Uint8List> 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,
Expand Down

0 comments on commit dbc6516

Please sign in to comment.