Skip to content

Commit

Permalink
Fixed parent context overwrite (#370)
Browse files Browse the repository at this point in the history
Overwriting parent context led to the routine at :49 unwanted exit.
  • Loading branch information
BoskyWSMFN authored Jun 13, 2024
1 parent 825bde1 commit a88c186
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Overwriting parent context in `*Config.Watch()` what led to unwanted routine exit.

## [1.2.0] - 2024-06-10

### Changed
Expand Down
7 changes: 3 additions & 4 deletions watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,13 @@ func (c *Config) Watch(ctx context.Context) error { //nolint:cyclop,funlen,gocog
}
}()

var tcancel context.CancelFunc
ctx, tcancel = context.WithTimeout(ctx, time.Minute)
tctx, tcancel := context.WithTimeout(ctx, time.Minute)
defer tcancel()
select {
case <-done:
c.log(ctx, slog.LevelDebug, "Configuration has been applied to onChanges.")
case <-ctx.Done():
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
case <-tctx.Done():
if errors.Is(tctx.Err(), context.DeadlineExceeded) {
c.log(
ctx, slog.LevelWarn,
"Configuration has not been fully applied to onChanges due to timeout."+
Expand Down

0 comments on commit a88c186

Please sign in to comment.