about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2025-03-27 15:29:36 +0100
committerAlan Pearce2025-03-27 15:29:36 +0100
commit75c2afdf214b0ddc57efe8e621eb172506c0b0f7 (patch)
tree4ee093b3cd0397db764c5b365dba4d89d9b82e18
parentf8f4f748c8528b7fe245d1e1f1d55f78b78ede39 (diff)
downloadsearchix-75c2afdf214b0ddc57efe8e621eb172506c0b0f7.tar.lz
searchix-75c2afdf214b0ddc57efe8e621eb172506c0b0f7.tar.zst
searchix-75c2afdf214b0ddc57efe8e621eb172506c0b0f7.zip
fix: importer timeout ignored in scheduler
-rw-r--r--internal/importer/main.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/importer/main.go b/internal/importer/main.go
index 184c6df..79be118 100644
--- a/internal/importer/main.go
+++ b/internal/importer/main.go
@@ -286,7 +286,7 @@ func (imp *Importer) EnsureSourcesIndexed(
 }
 
 func (imp *Importer) StartUpdateTimer(
-	ctx context.Context,
+	parentCtx context.Context,
 	localHub *sentry.Hub,
 ) {
 	const monitorSlug = "import"
@@ -311,7 +311,7 @@ func (imp *Importer) StartUpdateTimer(
 		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 @@ func (imp *Importer) StartUpdateTimer(
 			}, 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)