Skip to content

Commit

Permalink
attempt to throttle spawning lots of daemons before the first is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon authored and gsoltis committed May 5, 2023
1 parent 0171c9e commit 67bc954
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cli/internal/daemon/connector/connector.go
Expand Up @@ -128,6 +128,7 @@ const (
_maxAttempts = 10
_shutdownTimeout = 1 * time.Second
_socketPollTimeout = 1 * time.Second
_notReadyTimeout = 3 * time.Millisecond
)

// killLiveServer tells a running server to shut down. This method is also responsible
Expand Down Expand Up @@ -254,8 +255,11 @@ func (c *Connector) connectInternal(ctx context.Context) (*Client, error) {
}
// Loops back around and tries again.
} else if errors.Is(err, errUnavailable) {
// close the client, see if we can kill the stale daemon
// The rust daemon will open the socket a few ms before it's ready to accept connections.
// If we get here, we know that the socket exists, but the server isn't ready yet.
// We'll wait a few ms and try again.
c.Logger.Debug("server not ready yet")
time.Sleep(_notReadyTimeout)
} else if err != nil {
// Some other error occurred, close the client and
// report the error to the user
Expand Down

0 comments on commit 67bc954

Please sign in to comment.