diff --git a/ez/ez.go b/ez/ez.go index cbd77be..d32e9b6 100644 --- a/ez/ez.go +++ b/ez/ez.go @@ -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. @@ -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 {