Skip to content

[BUG] Unexpected Goroutine Leak in OpenFeature Go SDK in Test Environment. #471

@grambbledook

Description

@grambbledook

Brief Description

The event executor initiates a background goroutine during package initialization to manage FeatureProvider events, which remains active as no mechanism exists to signal its completion during testing..

Observed Behavior

A goroutine remains active after test completion:

  • Goroutine state: chan receive
  • Test suites using goleak.VerifyTestMain(m) fail during goroutine leak verification.

Stack trace

goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 21 in state chan receive, with github.com/open-feature/go-sdk/openfeature.(*eventExecutor).startEventListener.func1.1 on top of the stack:
github.com/open-feature/go-sdk/openfeature.(*eventExecutor).startEventListener.func1.1()
	/Users/denis/go/pkg/mod/github.com/open-feature/go-sdk@v1.17.0/openfeature/event_executor.go:278 +0xb0
created by github.com/open-feature/go-sdk/openfeature.(*eventExecutor).startEventListener.func1 in goroutine 1
	/Users/denis/go/pkg/mod/github.com/open-feature/go-sdk@v1.17.0/openfeature/event_executor.go:277 +0x60

Expected Behavior

All goroutines should be properly cleaned up after test execution, leaving no lingering background processes.

Steps to reproduce

You can find the complete reproducible example in this GitHub Gist: [goleak-openfeature-poc]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions