fix: address infinite hang when infisical run watch fails

This commit is contained in:
Sheen Capadngan
2025-01-10 02:29:39 +08:00
parent 9bc549ca8c
commit 02dc23425c
+4 -3
View File
@@ -419,12 +419,14 @@ func executeCommandWithWatchMode(commandFlag string, args []string, watchModeInt
for { for {
<-recheckSecretsChannel <-recheckSecretsChannel
func() {
watchMutex.Lock() watchMutex.Lock()
defer watchMutex.Unlock()
newEnvironmentVariables, err := fetchAndFormatSecretsForShell(request, projectConfigDir, secretOverriding, token) newEnvironmentVariables, err := fetchAndFormatSecretsForShell(request, projectConfigDir, secretOverriding, token)
if err != nil { if err != nil {
log.Error().Err(err).Msg("[HOT RELOAD] Failed to fetch secrets") log.Error().Err(err).Msg("[HOT RELOAD] Failed to fetch secrets")
continue return
} }
if newEnvironmentVariables.ETag != currentETag { if newEnvironmentVariables.ETag != currentETag {
@@ -433,8 +435,7 @@ func executeCommandWithWatchMode(commandFlag string, args []string, watchModeInt
log.Debug().Msg("[HOT RELOAD] No changes detected in secrets, not reloading process") log.Debug().Msg("[HOT RELOAD] No changes detected in secrets, not reloading process")
} }
watchMutex.Unlock() }()
} }
} }