From 16db33b7a27458fa605ab533101ade4b05ba8e47 Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Wed, 19 Oct 2016 15:12:59 -0700 Subject: [PATCH] Propagate errors correctly in Socket.connect socket.port can throw an exception. The error from the exception, if there is one, has to go to the completer, not be thrown up the stack, otherwise it may go to the enclosing Zone rather than e.g. a try ... catch around await Socket.connetc(). This is a possible fix for the issue below, but it is tough to say because I don't have a reliable repro. related #27440 R=asiva@google.com Review URL: https://codereview.chromium.org/2426413006 . --- runtime/bin/socket_patch.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart index 48508274a6e..cd02b29ab92 100644 --- a/runtime/bin/socket_patch.dart +++ b/runtime/bin/socket_patch.dart @@ -449,7 +449,12 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject { connectNext(); } else { // Query the local port, for error messages. - socket.port; + try { + socket.port; + } catch (e) { + error = createError(e, "Connection failed", address, port); + connectNext(); + } // Set up timer for when we should retry the next address // (if any). var duration = address.isLoopback ?