From af227cfcd2854c9eac8fa8c853ef1d82e518a221 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Wed, 23 Jul 2025 20:51:54 +0800 Subject: [PATCH] fix: check if synthesizeEvent timeout error and add extra retry --- uixt/driver_session.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/uixt/driver_session.go b/uixt/driver_session.go index 43bc1491..2cc26e0c 100644 --- a/uixt/driver_session.go +++ b/uixt/driver_session.go @@ -183,6 +183,8 @@ func (s *DriverSession) RequestWithRetry(method string, urlStr string, rawBody [ maxRetry = options.MaxRetryTimes } + synthesizeEventRetryAdded := false + for attempt := 1; attempt <= maxRetry; attempt++ { // Execute the request rawResp, err = s.Request(method, urlStr, rawBody, opts...) @@ -193,13 +195,20 @@ func (s *DriverSession) RequestWithRetry(method string, urlStr string, rawBody [ return rawResp, nil } + // only for WDA driver, check if "synthesizeEvent timeout" error and add extra retry + if strings.Contains(err.Error(), "synthesizeEvent timeout") && !synthesizeEventRetryAdded { + log.Warn().Err(err).Msg("synthesizeEvent timeout detected, adding one extra retry") + maxRetry++ + synthesizeEventRetryAdded = true + } + // Notice: use DeviceHTTPDriverError when request driver failed lastError = errors.Wrap(code.DeviceHTTPDriverError, err.Error()) - log.Warn().Err(err).Msgf("request failed, attempt %d/%d", attempt, s.maxRetry) + log.Warn().Err(err).Msgf("request failed, attempt %d/%d", attempt, maxRetry) // If this was the last attempt, break - if attempt == s.maxRetry { - log.Error().Err(lastError).Msgf("all %d retry attempts failed, giving up", s.maxRetry) + if attempt == maxRetry { + log.Error().Err(lastError).Msgf("all %d retry attempts failed, giving up", maxRetry) break }