Skip to content

Commit cca6a0b

Browse files
committed
log error on removing temp user data dir
1 parent 48a319c commit cca6a0b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

scaletest/dashboard/chromedp.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"github.com/chromedp/cdproto/network"
1212
"github.com/chromedp/chromedp"
1313
"golang.org/x/xerrors"
14+
15+
"cdr.dev/slog"
1416
)
1517

1618
// Action is just a function that does something.
@@ -150,7 +152,7 @@ func clickAndWait(ctx context.Context, clickOn, waitFor Selector) error {
150152
// initChromeDPCtx initializes a chromedp context with the given session token cookie
151153
//
152154
//nolint:revive // yes, headless is a control flag
153-
func initChromeDPCtx(ctx context.Context, u *url.URL, sessionToken string, headless bool) (context.Context, context.CancelFunc, error) {
155+
func initChromeDPCtx(ctx context.Context, log slog.Logger, u *url.URL, sessionToken string, headless bool) (context.Context, context.CancelFunc, error) {
154156
dir, err := os.MkdirTemp("", "scaletest-dashboard-*")
155157
if err != nil {
156158
return nil, nil, err
@@ -170,7 +172,9 @@ func initChromeDPCtx(ctx context.Context, u *url.URL, sessionToken string, headl
170172
cancelFunc := func() {
171173
cdpCancel()
172174
allocCtxCancel()
173-
_ = os.RemoveAll(dir)
175+
if err := os.RemoveAll(dir); err != nil {
176+
log.Error(ctx, "failed to remove temp user data dir", slog.F("dir", dir), slog.Error(err))
177+
}
174178
}
175179

176180
// set cookies

scaletest/dashboard/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (r *Runner) Run(ctx context.Context, _ string, _ io.Writer) error {
4747
return xerrors.Errorf("user has no organizations")
4848
}
4949

50-
cdpCtx, cdpCancel, err := initChromeDPCtx(ctx, r.client.URL, r.client.SessionToken(), r.cfg.Headless)
50+
cdpCtx, cdpCancel, err := initChromeDPCtx(ctx, r.cfg.Logger, r.client.URL, r.client.SessionToken(), r.cfg.Headless)
5151
if err != nil {
5252
return xerrors.Errorf("init chromedp ctx: %w", err)
5353
}

0 commit comments

Comments
 (0)