Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ func Evaluate(ctx context.Context, tape string, out io.Writer, opts ...Evaluator
if err := v.Start(); err != nil {
return []error{err}
}
defer func() { _ = v.close() }()
defer func() {
_ = v.close()
if v.tty != nil && v.tty.Process != nil {
_ = v.tty.Process.Kill()
}
}()

// Let's wait until we can access the window.term variable.
//
Expand Down
3 changes: 3 additions & 0 deletions vhs.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@ func (vhs *VHS) Start() error {
enableNoSandbox := os.Getenv("VHS_NO_SANDBOX") != ""
u, err := launcher.New().Leakless(false).Bin(path).NoSandbox(enableNoSandbox).Launch()
if err != nil {
_ = vhs.tty.Process.Kill()
return fmt.Errorf("could not launch browser: %w", err)
}
browser := rod.New().ControlURL(u).MustConnect()
page, err := browser.Page(proto.TargetCreateTarget{URL: fmt.Sprintf("http://localhost:%d", port)})
if err != nil {
browser.MustClose()
_ = vhs.tty.Process.Kill()
return fmt.Errorf("could not open ttyd: %w", err)
}

Expand Down