Skip to content

Commit

Permalink
fix: address infinite hang when infisical run watch fails
Browse files Browse the repository at this point in the history
  • Loading branch information
sheensantoscapadngan committed Jan 9, 2025
1 parent 9bc549c commit 02dc234
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions cli/packages/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,22 +419,23 @@ func executeCommandWithWatchMode(commandFlag string, args []string, watchModeInt

for {
<-recheckSecretsChannel
watchMutex.Lock()

newEnvironmentVariables, err := fetchAndFormatSecretsForShell(request, projectConfigDir, secretOverriding, token)
if err != nil {
log.Error().Err(err).Msg("[HOT RELOAD] Failed to fetch secrets")
continue
}

if newEnvironmentVariables.ETag != currentETag {
runCommandWithWatcher(newEnvironmentVariables)
} else {
log.Debug().Msg("[HOT RELOAD] No changes detected in secrets, not reloading process")
}
func() {
watchMutex.Lock()
defer watchMutex.Unlock()

newEnvironmentVariables, err := fetchAndFormatSecretsForShell(request, projectConfigDir, secretOverriding, token)
if err != nil {
log.Error().Err(err).Msg("[HOT RELOAD] Failed to fetch secrets")
return
}

watchMutex.Unlock()
if newEnvironmentVariables.ETag != currentETag {
runCommandWithWatcher(newEnvironmentVariables)
} else {
log.Debug().Msg("[HOT RELOAD] No changes detected in secrets, not reloading process")
}

}()
}
}

Expand Down

0 comments on commit 02dc234

Please sign in to comment.