Skip to content

Commit 2979f09

Browse files
committed
fix: increase timeout to 60 seconds for dump ui on ios
1 parent 03174fe commit 2979f09

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

devices/wda/requests.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ type sessionRequest struct {
2424
Capabilities sessionCapabilities `json:"capabilities"`
2525
}
2626

27-
func (c *WdaClient) GetEndpoint(endpoint string) (map[string]interface{}, error) {
27+
func (c *WdaClient) getEndpointWithTimeout(endpoint string, timeout time.Duration) (map[string]interface{}, error) {
2828
url := fmt.Sprintf("%s/%s", c.baseURL, endpoint)
2929

30-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
30+
ctx, cancel := context.WithTimeout(context.Background(), timeout)
3131
defer cancel()
3232

3333
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
@@ -62,6 +62,10 @@ func (c *WdaClient) GetEndpoint(endpoint string) (map[string]interface{}, error)
6262
return result, nil
6363
}
6464

65+
func (c *WdaClient) GetEndpoint(endpoint string) (map[string]interface{}, error) {
66+
return c.getEndpointWithTimeout(endpoint, 5*time.Second)
67+
}
68+
6569
func (c *WdaClient) PostEndpoint(endpoint string, data interface{}) (map[string]interface{}, error) {
6670
url := fmt.Sprintf("%s/%s", c.baseURL, endpoint)
6771
jsonData, err := json.Marshal(data)

devices/wda/source.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package wda
33
import (
44
"encoding/json"
55
"fmt"
6+
"time"
67

78
"github.com/mobile-next/mobilecli/types"
89
"github.com/mobile-next/mobilecli/utils"
@@ -79,7 +80,7 @@ func filterSourceElements(source sourceTreeElement) []types.ScreenElement {
7980
func (c *WdaClient) GetSource() (map[string]interface{}, error) {
8081
endpoint := "source?format=json"
8182

82-
result, err := c.GetEndpoint(endpoint)
83+
result, err := c.getEndpointWithTimeout(endpoint, 60*time.Second)
8384
if err != nil {
8485
return nil, fmt.Errorf("failed to get source: %w", err)
8586
}
@@ -91,7 +92,7 @@ func (c *WdaClient) GetSource() (map[string]interface{}, error) {
9192
func (c *WdaClient) GetSourceRaw() (interface{}, error) {
9293
endpoint := "source?format=json"
9394

94-
result, err := c.GetEndpoint(endpoint)
95+
result, err := c.getEndpointWithTimeout(endpoint, 60*time.Second)
9596
if err != nil {
9697
return nil, fmt.Errorf("failed to get source: %w", err)
9798
}

devices/wda/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func NewWdaClient(hostPort string) *WdaClient {
2424
return &WdaClient{
2525
baseURL: baseURL,
2626
httpClient: &http.Client{
27-
Timeout: 5 * time.Second,
27+
Timeout: 60 * time.Second,
2828
},
2929
}
3030
}

0 commit comments

Comments
 (0)