Skip to content

Commit

Permalink
Disable timeout on browser process execution (#866)
Browse files Browse the repository at this point in the history
* Disable timeout on browser process launch

This commit modifies the browser launching process to not pass a context
with timeout to the actual browser process cmd handle. Currently this
was done using as timeout the value set for the browser.timeout option,
which should serve a different purpose.

* Disable timeout on browser process connection

This commit modifies the browser connecting process to not pass a
context with timeout to the browser process implementation so its
closing handler is not triggered after the set timeout. Currently this
was done using as timeout the value set for the browser.timeout option,
which should serve a different purpose.
  • Loading branch information
ka3de committed May 9, 2023
1 parent a56b64d commit 3b6486c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions chromium/browser_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (b *BrowserType) Connect(wsEndpoint string, opts goja.Value) api.Browser {
func (b *BrowserType) connect(
ctx context.Context, wsURL string, opts *common.LaunchOptions, logger *log.Logger,
) (*common.Browser, error) {
browserProc, err := b.link(ctx, wsURL, opts, logger)
browserProc, err := b.link(ctx, wsURL, logger)
if browserProc == nil {
return nil, fmt.Errorf("connecting to browser: %w", err)
}
Expand All @@ -140,10 +140,9 @@ func (b *BrowserType) connect(
}

func (b *BrowserType) link(
ctx context.Context, wsURL string,
opts *common.LaunchOptions, logger *log.Logger,
ctx context.Context, wsURL string, logger *log.Logger,
) (*common.BrowserProcess, error) {
bProcCtx, bProcCtxCancel := context.WithTimeout(ctx, opts.Timeout)
bProcCtx, bProcCtxCancel := context.WithCancel(ctx)
p, err := common.NewRemoteBrowserProcess(bProcCtx, wsURL, bProcCtxCancel, logger)
if err != nil {
bProcCtxCancel()
Expand Down Expand Up @@ -236,7 +235,7 @@ func (b *BrowserType) allocate(
flags map[string]any, dataDir *storage.Dir,
logger *log.Logger,
) (_ *common.BrowserProcess, rerr error) {
bProcCtx, bProcCtxCancel := context.WithTimeout(ctx, opts.Timeout)
bProcCtx, bProcCtxCancel := context.WithCancel(ctx)
defer func() {
if rerr != nil {
bProcCtxCancel()
Expand Down

0 comments on commit 3b6486c

Please sign in to comment.