Add timeout option to Playwright server connection

Introduced a 30-second timeout for connecting to the Playwright server. Added logging for connection attempts to improve debugging and enhance connection reliability.
This commit is contained in:
2025-10-10 20:25:27 -04:00
parent 9947cae947
commit f4caef22b0

View File

@@ -167,7 +167,9 @@ func NewPlayWrightBrowser(opts ...PlayWrightBrowserOptions) (Browser, error) {
var launch = true
if opt.PlayWrightServerAddress != "" {
launch = false
browser, err = bt.Connect(opt.PlayWrightServerAddress, playwright.BrowserTypeConnectOptions{})
slog.Info("connecting to playwright server", "address", opt.PlayWrightServerAddress)
var timeout float64 = 30000
browser, err = bt.Connect(opt.PlayWrightServerAddress, playwright.BrowserTypeConnectOptions{Timeout: &timeout})
if err != nil {
if opt.DontLaunchOnConnectFailure {