Skip to content

Commit 04e404e

Browse files
authored
chore: dial the remote socket continually until connect (coder#6891)
It's possible that the command starts but the socket isn't ready even when the file exists.
1 parent 5686fc9 commit 04e404e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

agent/agent_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,14 @@ func TestAgent_UnixRemoteForwarding(t *testing.T) {
673673
err = cmd.Start()
674674
require.NoError(t, err)
675675

676+
// It's possible that the socket is created but the server is not ready to
677+
// accept connections yet. We need to retry until we can connect.
678+
var conn net.Conn
676679
require.Eventually(t, func() bool {
677-
_, err := os.Stat(remoteSocketPath)
680+
var err error
681+
conn, err = net.Dial("unix", remoteSocketPath)
678682
return err == nil
679-
}, testutil.WaitLong, testutil.IntervalFast)
680-
681-
conn, err := net.Dial("unix", remoteSocketPath)
682-
require.NoError(t, err)
683+
}, testutil.WaitShort, testutil.IntervalFast)
683684
defer conn.Close()
684685
_, err = conn.Write([]byte("test"))
685686
require.NoError(t, err)

0 commit comments

Comments
 (0)