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

Lines changed: 6 additions & 5 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy