Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout to chrome launch #722

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading