Skip to content
This repository was archived by the owner on Aug 30, 2020. It is now read-only.

Commit cb333af

Browse files
committed
scheduled task mem leak by chrome ctx reused
1 parent 3a24c57 commit cb333af

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func main() {
5050
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
5151
defer cancel()
5252
if err := e.Shutdown(ctx); err != nil {
53-
e.Logger.Printf("shutting down with error")
53+
e.Logger.Printf("ERROR: Main: shutting down with error")
5454
e.Logger.Fatal(err)
5555
}
5656
}

trackers/chrome_tracker.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ func init() {
3535
// and returns content/error message, ok
3636
func ChromeTracker(url, xpath *string) (string, bool) {
3737
ctx, cancel := context.WithTimeout(context.Background(), chromeTimeout)
38+
ctx1, cancel1 := context.WithTimeout(context.Background(), chromeTimeout)
3839
defer cancel()
40+
defer cancel1()
3941
opts := []runner.CommandLineOption{runner.Flag("headless", true)}
4042
if chromePath != "" {
4143
opts = append(opts, runner.Path(chromePath))
@@ -56,7 +58,7 @@ func ChromeTracker(url, xpath *string) (string, bool) {
5658
}
5759

5860
// run the tasks
59-
if err := c.Run(ctx, tasks); err != nil {
61+
if err := c.Run(ctx1, tasks); err != nil {
6062
log.Println(err)
6163
return err.Error(), false
6264
}

0 commit comments

Comments
 (0)