From a59ac47ecac4b38033aad2774e9888a2bd011b27 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Wed, 4 Dec 2024 17:37:24 +0800 Subject: [PATCH] fix: set timeout for WDA request --- hrp/internal/version/VERSION | 2 +- hrp/pkg/uixt/client.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 44b4ae6d..fc4a438a 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2412021645 +v5.0.0+2412041737 diff --git a/hrp/pkg/uixt/client.go b/hrp/pkg/uixt/client.go index dfc9b523..171c819b 100644 --- a/hrp/pkg/uixt/client.go +++ b/hrp/pkg/uixt/client.go @@ -108,8 +108,11 @@ func (wd *Driver) httpDELETE(pathElem ...string) (rawResp rawResponse, err error func (wd *Driver) httpRequest(method string, rawURL string, rawBody []byte) (rawResp rawResponse, err error) { log.Debug().Str("method", method).Str("url", rawURL).Str("body", string(rawBody)).Msg("request driver agent") + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + var req *http.Request - if req, err = http.NewRequest(method, rawURL, bytes.NewBuffer(rawBody)); err != nil { + if req, err = http.NewRequestWithContext(ctx, method, rawURL, bytes.NewBuffer(rawBody)); err != nil { return nil, err } req.Header.Set("Content-Type", "application/json;charset=UTF-8") @@ -162,6 +165,6 @@ func convertToHTTPClient(conn net.Conn) *http.Client { return conn, nil }, }, - Timeout: 0, + Timeout: 30 * time.Second, } }