Skip to content

Commit

Permalink
Merge pull request #2962 from Infisical/fix/address-indefinite-hang-f…
Browse files Browse the repository at this point in the history
…or-run-watch-failure

fix: address infinite hang when infisical run watch fails
  • Loading branch information
sheensantoscapadngan authored Jan 10, 2025
2 parents 3ed3856 + 02dc234 commit 9cde199
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 9cde199

Please sign in to comment.