Skip to content

Commit

Permalink
slight delay in starting up server... maybe will help w/ flaky 'no re…
Browse files Browse the repository at this point in the history
…cent network activity' http3 issues?
  • Loading branch information
jhump committed Dec 11, 2023
1 parent a207f16 commit 8809aa4
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions internal/app/referenceserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ func run(ctx context.Context, referenceMode bool, args []string, inReader io.Rea
return err
}

// Start the server
var serveError error
serveDone := make(chan struct{})
go func() {
defer close(serveDone)
serveError = server.Serve()
}()
// Give the above goroutine a chance to start the server and potentially
// abort if it could not be started.
time.Sleep(200 * time.Millisecond)
select {
case <-serveDone:
return serveError
default:
}

resp := &v1.ServerCompatResponse{
Host: actualHost,
Port: uint32(actualPort),
Expand All @@ -100,13 +116,6 @@ func run(ctx context.Context, referenceMode bool, args []string, inReader io.Rea
return err
}

// Finally, start the server
var serveError error
serveDone := make(chan struct{})
go func() {
defer close(serveDone)
serveError = server.Serve()
}()
select {
case <-serveDone:
return serveError
Expand Down

0 comments on commit 8809aa4

Please sign in to comment.