Skip to content

Commit 582f2e1

Browse files
committed
Fix: Correct Chrome proxy URL and optimize element timeouts
Corrects the Chrome proxy PAC URL configuration to consistently use the first instance's proxy settings, resolving a potential misconfiguration. Reduces the `GetElements` timeout from 1s to 500ms for faster element retrieval and improved responsiveness. The `GetElement` timeout was also updated to use milliseconds for consistency. Updates the `runner` submodule.
1 parent d75a729 commit 582f2e1

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

internal/browser/chrome/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func NewManager(appConfig *config.AppConfig, indies ...int) (*Manager, error) {
5656
}
5757

5858
if len(indies) > 0 {
59-
if appConfig.Instance[indies[0]].ProxyURL != "" {
59+
if appConfig.Instance[0].ProxyURL != "" {
6060
opts = append(opts, chromedp.Flag("proxy-pac-url", fmt.Sprintf("http://127.0.0.1:2048/proxy.pac?index=%d", indies[0])))
6161
}
6262
} else {

internal/method/element.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
func (m *Method) GetElements(elementSelector string) ([]*cdp.Node, error) {
1515
var nodes []*cdp.Node
16-
ctx, cancel := context.WithTimeout(m.page.GetContext(), 1*time.Second)
16+
ctx, cancel := context.WithTimeout(m.page.GetContext(), 500*time.Millisecond)
1717
err := chromedp.Run(ctx,
1818
chromedp.Nodes(elementSelector, &nodes, chromedp.ByQueryAll),
1919
)
@@ -41,7 +41,7 @@ func (m *Method) GetElement(elementSelector string) (*cdp.Node, error) {
4141
var nodes []*cdp.Node
4242
// ByQuery by default gets the first element.
4343
// Using AtLeast(0) so it doesn't error if not found by Nodes action itself, we check len(nodes) ourselves.
44-
ctx, cancel := context.WithTimeout(m.page.GetContext(), 3*time.Second)
44+
ctx, cancel := context.WithTimeout(m.page.GetContext(), 3000*time.Millisecond)
4545
err := chromedp.Run(ctx,
4646
chromedp.Nodes(elementSelector, &nodes, chromedp.ByQueryAll),
4747
)

runner

Submodule runner updated 1 file

0 commit comments

Comments
 (0)