Skip to content

Commit db9104c

Browse files
authored
fix: avoid panic on nil connection (coder#11305)
Related to https://github.com/coder/coder/actions/runs/7286675441/job/19855871305 Fixes a panic if the listener returns an error, which can obfuscate the underlying problem and cause unrelated tests to be marked failed.
1 parent fe867d0 commit db9104c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

agent/agent_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,9 +1635,10 @@ func TestAgent_Dial(t *testing.T) {
16351635
go func() {
16361636
defer close(done)
16371637
c, err := l.Accept()
1638-
assert.NoError(t, err, "accept connection")
1639-
defer c.Close()
1640-
testAccept(ctx, t, c)
1638+
if assert.NoError(t, err, "accept connection") {
1639+
defer c.Close()
1640+
testAccept(ctx, t, c)
1641+
}
16411642
}()
16421643

16431644
//nolint:dogsled

0 commit comments

Comments
 (0)