Skip to content

Conversation

@nicklasl
Copy link
Member

@nicklasl nicklasl commented Nov 5, 2025

Summary

Fixes shutdown flow in the Go OpenFeature provider by implementing the StateHandler interface.

Problem

The OpenFeature Go SDK only calls Shutdown() on providers that implement the full StateHandler interface (both Init() and Shutdown() methods). Without this, openfeature.Shutdown() would not trigger provider cleanup, leaving logs unflushed and resources unreleased.

Solution

  • Implement StateHandler interface with Init() and Shutdown() methods
  • Add sync.WaitGroup to prevent race conditions during shutdown
  • Ensure ticker goroutine exits immediately on context cancellation
  • Proper shutdown sequence: cancel context → wait for goroutines → flush logs → close WASM

Testing

  • Shutdown completes fast with no race conditions or panics

@nicklasl nicklasl marked this pull request as ready for review November 5, 2025 15:22
Implement StateHandler interface to ensure OpenFeature SDK calls
provider shutdown. Add WaitGroup synchronization to prevent race
conditions during cleanup.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

wip
@nicklasl nicklasl force-pushed the fix-go-shutdown-bug branch from 19c8c4b to 9cd6dc5 Compare November 6, 2025 08:18

// Shutdown closes the provider and cleans up resources
// Init initializes the provider (part of StateHandler interface)
func (p *LocalResolverProvider) Init(evaluationContext openfeature.EvaluationContext) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The absense of this function was the reason that openfeature.Shutdown() didn't work.

@nicklasl nicklasl force-pushed the fix-go-shutdown-bug branch from 45ed5fe to c277c3f Compare November 6, 2025 10:46
@nicklasl nicklasl merged commit 6041e45 into main Nov 6, 2025
10 checks passed
@nicklasl nicklasl deleted the fix-go-shutdown-bug branch November 6, 2025 14:22
This was referenced Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants