Add logging for faulted tasks on successful connections

- Diagnostic tool, we don't really care about these exceptions.
This commit is contained in:
Kaz Wolfe 2023-04-29 13:22:15 -07:00
parent 76190d7e59
commit ec829b4eee
No known key found for this signature in database
GPG key ID: 258813F53A16EBB4

View file

@ -83,12 +83,7 @@ public class HappyEyeballsCallback : IDisposable
// If we're here, it means we have a successful connection. A failure to connect would have caused the above
// line to explode, so we're safe to clean everything up.
linkedToken.Cancel();
tasks.ForEach(task =>
{
// Suppress any other exceptions that come down the pipe. We've already thrown an exception we cared
// about above.
task.ContinueWith(inner => { _ = inner.Exception; });
});
tasks.ForEach(task => { task.ContinueWith(this.CleanupConnectionTask); });
return stream;
}
@ -133,4 +128,16 @@ public class HappyEyeballsCallback : IDisposable
return Util.ZipperMerge(groups).ToList();
}
private void CleanupConnectionTask(Task task)
{
// marks the exception as handled as well, nifty!
// will also handle canceled cases, which aren't explicitly faulted.
var exception = task.Exception;
if (task.IsFaulted)
{
Log.Verbose(exception!, "A HappyEyeballs connection task failed. Are there network issues?");
}
}
}