// Connect request callback from libuv thread
            void INativeUnsafe.FinishConnect(ConnectRequest request)
            {
                var ch = (NativeChannel)this.channel;

                ch.connectCancellationTask?.Cancel();

                TaskCompletionSource promise = ch.connectPromise;
                bool success = false;

                try
                {
                    if (promise != null) // Not cancelled from timed out
                    {
                        OperationException error = request.Error;
                        if (error != null)
                        {
                            if (error.ErrorCode == ErrorCode.ETIMEDOUT)
                            {
                                // Connection timed out should use the standard ConnectTimeoutException
                                promise.TrySetException(new ConnectTimeoutException(error.ToString()));
                            }
                            else
                            {
                                promise.TrySetException(new ChannelException(error));
                            }
                        }
                        else
                        {
                            bool wasActive = ch.Active;
                            ch.DoFinishConnect();
                            success = promise.TryComplete();

                            // Regardless if the connection attempt was cancelled, channelActive()
                            // event should be triggered, because what happened is what happened.
                            if (!wasActive && ch.Active)
                            {
                                ch.Pipeline.FireChannelActive();
                            }
                        }
                    }
                }
                finally
                {
                    request.Dispose();
                    ch.connectPromise = null;
                    if (!success)
                    {
                        this.CloseSafe();
                    }
                }
            }