all repos — searchix @ 75c2afdf214b0ddc57efe8e621eb172506c0b0f7

Search engine for NixOS, nix-darwin, home-manager and NUR users

fix: importer timeout ignored in scheduler
Alan Pearce alan@alanpearce.eu
Thu, 27 Mar 2025 15:29:36 +0100
commit

75c2afdf214b0ddc57efe8e621eb172506c0b0f7

parent

f8f4f748c8528b7fe245d1e1f1d55f78b78ede39

1 files changed, 5 insertions(+), 2 deletions(-)

jump to
M internal/importer/main.gointernal/importer/main.go
@@ -286,7 +286,7 @@ return nil }
 
 func (imp *Importer) StartUpdateTimer(
-	ctx context.Context,
+	parentCtx context.Context,
 	localHub *sentry.Hub,
 ) {
 	const monitorSlug = "import"
@@ -311,7 +311,7 @@ SetNextRun(nextRun) 		for {
 			imp.log.Debug("scheduling next run", "next-run", nextRun)
 			select {
-			case <-ctx.Done():
+			case <-parentCtx.Done():
 				imp.log.Debug("stopping scheduler")
 
 				return
@@ -325,7 +325,10 @@ Status:      sentry.CheckInStatusInProgress, 			}, monitorConfig)
 			MarkIndexingStarted()
 
+			ctx, cancel := context.WithTimeout(parentCtx, imp.config.Importer.Timeout.Duration)
 			err = imp.Start(ctx, false, nil)
+			cancel()
+
 			if err != nil {
 				imp.log.Warn("error updating index", "error", err)