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 .
This commit is contained in:
Zachary Anderson 2016-10-19 15:12:59 -07:00
parent 9d29251368
commit 16db33b7a2

View file

@ -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 ?