Version 2.12.0-259.14.beta
* Cherry-pick 9cbed612045f455f5fd315392e3fe2e3be9c130d to beta
* Cherry-pick refs/changes/00/185100/1 to beta
diff --git a/DEPS b/DEPS
index 00cb7f7..4180192 100644
--- a/DEPS
+++ b/DEPS
@@ -133,7 +133,7 @@
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
"pool_rev": "7abe634002a1ba8a0928eded086062f1307ccfae",
"protobuf_rev": "0d03fd588df69e9863e2a2efc0059dee8f18d5b2",
- "pub_rev": "0e657414a472e74ca5dd76ae0db50cc060251dec",
+ "pub_rev": "0db3255b72db2957d50ea4f13c5c23835f42e5c6",
"pub_semver_rev": "10569a1e867e909cf5db201f73118020453e5db8",
"resource_rev": "6b79867d0becf5395e5819a75720963b8298e9a7",
"root_certificates_rev": "7e5ec82c99677a2e5b95ce296c4d68b0d3378ed8",
diff --git a/sdk/lib/_http/http_impl.dart b/sdk/lib/_http/http_impl.dart
index eac06c4..e99a58d 100644
--- a/sdk/lib/_http/http_impl.dart
+++ b/sdk/lib/_http/http_impl.dart
@@ -2219,25 +2219,10 @@
Future socketFuture = task.socket;
final Duration? connectionTimeout = client.connectionTimeout;
if (connectionTimeout != null) {
- socketFuture = socketFuture.timeout(connectionTimeout, onTimeout: () {
- _socketTasks.remove(task);
- task.cancel();
- return null;
- });
+ socketFuture = socketFuture.timeout(connectionTimeout);
}
return socketFuture.then((socket) {
- // When there is a timeout, there is a race in which the connectionTask
- // Future won't be completed with an error before the socketFuture here
- // is completed with 'null' by the onTimeout callback above. In this
- // case, propagate a SocketException as specified by the
- // HttpClient.connectionTimeout docs.
_connecting--;
- if (socket == null) {
- assert(connectionTimeout != null);
- throw new SocketException(
- "HTTP connection timed out after ${connectionTimeout}, "
- "host: ${host}, port: ${port}");
- }
socket.setOption(SocketOption.tcpNoDelay, true);
var connection =
new _HttpClientConnection(key, socket, client, false, context);
@@ -2258,6 +2243,20 @@
return new _ConnectionInfo(connection, proxy);
}
}, onError: (error) {
+ // When there is a timeout, there is a race in which the connectionTask
+ // Future won't be completed with an error before the socketFuture here
+ // is completed with a TimeoutException by the onTimeout callback above.
+ // In this case, propagate a SocketException as specified by the
+ // HttpClient.connectionTimeout docs.
+ if (error is TimeoutException) {
+ assert(connectionTimeout != null);
+ _connecting--;
+ _socketTasks.remove(task);
+ task.cancel();
+ throw SocketException(
+ "HTTP connection timed out after ${connectionTimeout}, "
+ "host: ${host}, port: ${port}");
+ }
_socketTasks.remove(task);
_checkPending();
throw error;
diff --git a/tests/standalone/io/regress_44895.dart b/tests/standalone/io/regress_44895.dart
new file mode 100644
index 0000000..38c0110a
--- /dev/null
+++ b/tests/standalone/io/regress_44895.dart
@@ -0,0 +1,17 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "dart:io";
+
+void main() {
+ final client = HttpClient();
+ client.connectionTimeout = Duration.zero;
+ // Should not throw a type error.
+ client.openUrl(
+ 'get',
+ Uri.parse(
+ 'https://localhost/',
+ ),
+ );
+}
diff --git a/tools/VERSION b/tools/VERSION
index 856cb76..325a6a0 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -28,4 +28,4 @@
MINOR 12
PATCH 0
PRERELEASE 259
-PRERELEASE_PATCH 12
\ No newline at end of file
+PRERELEASE_PATCH 14
\ No newline at end of file