Add context support to Playwright browser initialization

Refactored Playwright initialization to ensure context propagation. Updated `NewPlayWrightBrowser` and related methods to accept `context.Context` for better cancellation and timeout handling. Improved error resilience and concurrency during browser setup.
This commit is contained in:
2025-10-28 00:24:19 -04:00
parent 82fce5a200
commit 868acfae40
2 changed files with 154 additions and 119 deletions

View File

@@ -43,7 +43,7 @@ var Flags = BrowserFlags{
},
}
func FromCommand(_ context.Context, cmd *cli.Command) (extractor.Browser, error) {
func FromCommand(ctx context.Context, cmd *cli.Command) (extractor.Browser, error) {
var opts extractor.PlayWrightBrowserOptions
if ua := cmd.String("user-agent"); ua != "" {
@@ -72,5 +72,5 @@ func FromCommand(_ context.Context, cmd *cli.Command) (extractor.Browser, error)
opts.ShowBrowser = cmd.Bool("visible")
return extractor.NewPlayWrightBrowser(opts)
return extractor.NewPlayWrightBrowser(ctx, opts)
}