Skip to content

Commit

Permalink
Fix Source Error Hang
Browse files Browse the repository at this point in the history
This fixes a bug in ez where an error thrown by a Source may cause the
process to hang.
  • Loading branch information
sergiosalvatore committed Aug 29, 2024
1 parent 402b482 commit 4f66430
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ez/ez.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,6 @@ func ConfigFileEnvFlagDecoderFactoryParams[T any, TP ConfigWithConfigPath[T]](ct
flagSrc = fset
}

// If file-watching is not enabled, we should shutdown the monitor
// goroutine when exiting this function.
// Usually `dials.Config` is smart enough not to start a monitor when
// there are no `Watcher` implementations in the source-list, but the
// `Blank` source uses `Watcher` for its core functionality, so we need
// to shutdown the blank source to actually clean up resources.
if !params.WatchConfigFile {
defer blank.Done(ctx)
}

dp := dials.Params[T]{
// Set the OnNewConfig callback. It'll be suppressed by the
// CallGlobalCallbacksAfterVerificationEnabled until just before we return.
Expand All @@ -199,6 +189,16 @@ func ConfigFileEnvFlagDecoderFactoryParams[T any, TP ConfigWithConfigPath[T]](ct
return nil, err
}

// If file-watching is not enabled, we should shutdown the monitor
// goroutine when exiting this function.
// Usually `dials.Config` is smart enough not to start a monitor when
// there are no `Watcher` implementations in the source-list, but the
// `Blank` source uses `Watcher` for its core functionality, so we need
// to shutdown the blank source to actually clean up resources.
if !params.WatchConfigFile {
defer blank.Done(ctx)
}

basecfg := d.View()
cfgPath, filepathSet := (TP)(basecfg).ConfigPath()
if !filepathSet {
Expand Down

0 comments on commit 4f66430

Please sign in to comment.