Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,6 @@ func runConnectionWebSocketAgentCommand(flags *ConnectFlags, c *command, args []
c.PrintErrf("Failed to accept ADB socket: %v", err)
return err
}
defer tcpConn.Close()

// Connect to ADB proxy WebSocket
// wss://127.0.0.1:1443/devices/cvd-1/adb
Expand Down Expand Up @@ -1321,12 +1320,12 @@ func runConnectionWebSocketAgentCommand(flags *ConnectFlags, c *command, args []
pos: 0,
buf: nil,
}
defer wsWrapper.Close()
go func() {
io.Copy(wsWrapper, tcpConn)
wsWrapper.Close()
}()
io.Copy(tcpConn, wsWrapper)
tcpConn.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should stay as it was, with the defer in line 1275. It has the same effect of closing at the end of the function, but with the added benefit of closing the socket even with an early return in case of errors.

I wrongly suggested before that this one needed fixing because I had the order of parameters to io.Copy inverted. Sorry about that.

return nil
}

Expand Down