diff --git a/core/comment/service.go b/core/comment/service.go index a3e59e4fe..2e934523d 100644 --- a/core/comment/service.go +++ b/core/comment/service.go @@ -67,6 +67,7 @@ func (s *Service) Create(ctx context.Context, c *domain.Comment) error { } go func() { + ctx := context.WithoutCancel(ctx) if err := s.auditLogger.Log(ctx, AuditKeyCreate, c); err != nil { s.logger.Error(ctx, "failed to record audit log", "error", err, "appeal_id", c.ParentID, "comment_id", c.ID) } diff --git a/core/policy/service.go b/core/policy/service.go index 672f4bed4..5d1ead63c 100644 --- a/core/policy/service.go +++ b/core/policy/service.go @@ -120,6 +120,7 @@ func (s *Service) Create(ctx context.Context, p *domain.Policy) error { } go func() { + ctx := context.WithoutCancel(ctx) if err := s.auditLogger.Log(ctx, AuditKeyPolicyCreate, p); err != nil { s.logger.Error(ctx, "failed to record audit log", "error", err) } @@ -232,6 +233,7 @@ func (s *Service) Update(ctx context.Context, p *domain.Policy) error { } go func() { + ctx := context.WithoutCancel(ctx) if err := s.auditLogger.Log(ctx, AuditKeyPolicyUpdate, p); err != nil { s.logger.Error(ctx, "failed to record audit log", "error", err) } diff --git a/core/resource/service.go b/core/resource/service.go index dccbe5e89..abffbe1b3 100644 --- a/core/resource/service.go +++ b/core/resource/service.go @@ -79,6 +79,7 @@ func (s *Service) BulkUpsert(ctx context.Context, resources []*domain.Resource) } go func() { + ctx := context.WithoutCancel(ctx) if err := s.auditLogger.Log(ctx, AuditKeyResoruceBulkUpsert, resources); err != nil { s.logger.Error(ctx, "failed to record audit log", "error", err) } @@ -122,6 +123,7 @@ func (s *Service) Update(ctx context.Context, r *domain.Resource) error { r.UpdatedAt = res.UpdatedAt go func() { + ctx := context.WithoutCancel(ctx) if err := s.auditLogger.Log(ctx, AuditKeyResourceUpdate, r); err != nil { s.logger.Error(ctx, "failed to record audit log", "error", err) } @@ -165,6 +167,7 @@ func (s *Service) Delete(ctx context.Context, id string) error { s.logger.Info(ctx, "resource deleted", "resource", id) go func() { + ctx := context.WithoutCancel(ctx) if err := s.auditLogger.Log(ctx, AuditKeyResourceDelete, map[string]interface{}{"id": id}); err != nil { s.logger.Error(ctx, "failed to record audit log", "error", err) } @@ -181,6 +184,7 @@ func (s *Service) BatchDelete(ctx context.Context, ids []string) error { s.logger.Info(ctx, "resources deleted", "resources", len(ids)) go func() { + ctx := context.WithoutCancel(ctx) if err := s.auditLogger.Log(ctx, AuditKeyResourceBatchDelete, map[string]interface{}{"ids": ids}); err != nil { s.logger.Error(ctx, "failed to record audit log", "error", err) }