Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Fix resource leak
Browse files Browse the repository at this point in the history
  • Loading branch information
diegobernardes committed Jul 21, 2020
1 parent 0a22096 commit 284b55b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/service/provider/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ func (w Web) validAnchorBrowser(ctx context.Context, endpoint string, anchor str
if err != nil {
return false, fmt.Errorf("failed to create the browser page: %w", err)
}
defer func() {
if perr := page.CloseE(); perr != nil {
err = fmt.Errorf("failed to close the browser tab: %w", perr)
}
}()

if _, err = page.Context(pctx, pctxCancel).SetExtraHeadersE(w.genHeaders(endpoint)); err != nil {
return false, fmt.Errorf("failed to set the headers at the browser page: %w", err)
Expand All @@ -222,11 +227,6 @@ func (w Web) validAnchorBrowser(ctx context.Context, endpoint string, anchor str
if err := page.WaitLoadE(); err != nil {
return false, fmt.Errorf("failed to wait for the page to load: %w", err)
}
defer func() {
if perr := page.CloseE(); perr != nil {
err = fmt.Errorf("failed to close the browser tab: %w", perr)
}
}()

result, err := page.EvalE(true, "", "document.documentElement.innerHTML", nil)
if err != nil {
Expand Down

0 comments on commit 284b55b

Please sign in to comment.