From 4eb8455128a1a74a86312679b6b44d0bf00afe9c Mon Sep 17 00:00:00 2001 From: Rishabh Mishra Date: Tue, 27 Aug 2024 10:20:54 +0530 Subject: [PATCH] fix: memory leak issue in invoice sync (#747) --- billing/invoice/service.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/billing/invoice/service.go b/billing/invoice/service.go index 45eb22158..c996c3bf9 100644 --- a/billing/invoice/service.go +++ b/billing/invoice/service.go @@ -61,7 +61,11 @@ func (s *Service) Init(ctx context.Context) error { s.syncJob.Stop() } - s.syncJob = cron.New() + s.syncJob = cron.New(cron.WithChain( + cron.SkipIfStillRunning(cron.DefaultLogger), + cron.Recover(cron.DefaultLogger), + )) + if _, err := s.syncJob.AddFunc(fmt.Sprintf("@every %s", s.syncDelay.String()), func() { ctx, cancel := context.WithCancel(ctx) defer cancel()