Skip to content

Commit

Permalink
fix client.StartTunnel() retry logic - no more empty request bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
iximiuz committed Nov 21, 2024
1 parent ded08a3 commit 782477e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/api/plays.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,18 @@ type StartTunnelResponse struct {
}

func (c *Client) StartTunnel(ctx context.Context, id string, req StartTunnelRequest) (*StartTunnelResponse, error) {
body, err := toJSONBody(req)
if err != nil {
return nil, err
}

// A hacky workaround for the fact that the CLI currently
// doesn't check for playground readiness before establishing
// a tunnel.
backoff := 200 * time.Millisecond
for attempt := 0; attempt < 5; attempt++ {
body, err := toJSONBody(req)
if err != nil {
return nil, err
}

var resp StartTunnelResponse
err := c.PostInto(ctx, "/plays/"+id+"/tunnels", nil, nil, body, &resp)
err = c.PostInto(ctx, "/plays/"+id+"/tunnels", nil, nil, body, &resp)
if err == nil {
return &resp, nil
}
Expand Down

0 comments on commit 782477e

Please sign in to comment.