Merge pull request #2962 from Infisical/fix/address-indefinite-hang-for-run-watch-failure

fix: address infinite hang when infisical run watch fails
This commit is contained in:
Sheen
2025-01-10 11:54:51 +08:00
committed by GitHub
+14 -13
View File
@@ -419,22 +419,23 @@ func executeCommandWithWatchMode(commandFlag string, args []string, watchModeInt
for { for {
<-recheckSecretsChannel <-recheckSecretsChannel
watchMutex.Lock() func() {
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 {
runCommandWithWatcher(newEnvironmentVariables) runCommandWithWatcher(newEnvironmentVariables)
} else { } else {
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()
}()
} }
} }