Skip to content

Commit

Permalink
add timeout to chrome launch
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 committed Jul 11, 2024
1 parent 6b66782 commit a8f70bf
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/pipeline/source/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
endRecordingLog = "END_RECORDING"

chromeFailedToStart = "chrome failed to start:"
chromeTimeout = time.Second * 30
)

type WebSource struct {
Expand Down Expand Up @@ -83,8 +84,19 @@ func NewWebSource(ctx context.Context, p *config.PipelineConfig) (*WebSource, er
return nil, err
}

if err := s.launchChrome(ctx, p, p.Insecure); err != nil {
logger.Warnw("failed to launch chrome", err, "display", p.Display)
var err error
chromeErr := make(chan error, 1)
go func() {
chromeErr <- s.launchChrome(ctx, p, p.Insecure)
}()
select {
case err = <-chromeErr:
// chrome launch completed
case <-time.After(chromeTimeout):
err = errors.ErrPageLoadFailed("timed out")
}
if err != nil {
logger.Warnw("failed to launch chrome", err)
s.Close()
return nil, err
}
Expand Down

0 comments on commit a8f70bf

Please sign in to comment.