Skip to content

fix: Handle closed EventChannel from multiprovider#461

Merged
beeme1mr merged 5 commits intoopen-feature:mainfrom
superfly:saleem-fix-multiprovider
Jan 13, 2026
Merged

fix: Handle closed EventChannel from multiprovider#461
beeme1mr merged 5 commits intoopen-feature:mainfrom
superfly:saleem-fix-multiprovider

Conversation

@saleemrashid
Copy link
Contributor

This PR

This fixes a bug where the multiprovider is briefly READY, then becomes NOT_READY.

The multiprovider closes the event channel under certain circumstances, e.g.:

	if len(handlers) > 0 {
		p.workerGroup.Add(1)
		go p.forwardProviderEvents(workerCtx, handlers)
	} else {
		// we don't emit any events so we can just close the channel
		close(p.outboundEvents)
	}

But the eventExecutor goroutine copying from the provider's event channel was not checking if it was closed, so it was constantly reading zero-value events. This resulted in triggerEvent being called constantly with zero-value events, for which stateFromEvent returns NotReady.

@saleemrashid saleemrashid requested review from a team as code owners January 13, 2026 01:26
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @saleemrashid, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an intermittent state management problem within the multiprovider, preventing it from incorrectly reporting a NOT_READY status. The fix ensures that the system gracefully handles closed event channels, thereby maintaining accurate provider state and preventing the processing of spurious events that could lead to erroneous state transitions.

Highlights

  • Bug Fix: Multiprovider State: Addresses a bug where the multiprovider would briefly become READY and then incorrectly transition to NOT_READY.
  • Root Cause: Unhandled Closed Channel: The issue stemmed from the eventExecutor goroutine continuously reading zero-value events from a closed provider event channel, leading to constant NotReady state updates.
  • Solution: Channel Closure Check: Implemented a check for channel closure (ok value) when reading from the event channel in eventExecutor, ensuring that processing stops when the channel is closed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request modifies openfeature/event_executor.go to enhance robustness when handling events. Specifically, a check if !ok { return } was added when receiving from v.EventChannel() within the startListeningAndShutdownOld function. This ensures that the goroutine gracefully exits if the event channel is closed, preventing potential panics or unexpected behavior.

The multiprovider closes the event channel under certain circumstances
but the event processor was not handling this. This resulted in triggerEvent
being called with zero-value events, for which stateFromEvent returns NotReady,
resulting in the multiprovider being briefly READY and then becoming NOT_READY.

Signed-off-by: Saleem Rashid <dev@saleemrashid.com>
@saleemrashid saleemrashid force-pushed the saleem-fix-multiprovider branch from 510f98b to d0a596a Compare January 13, 2026 01:28
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.11%. Comparing base (4ee43eb) to head (92a0346).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #461   +/-   ##
=======================================
  Coverage   83.11%   83.11%           
=======================================
  Files          27       27           
  Lines        2097     2097           
=======================================
  Hits         1743     1743           
  Misses        305      305           
  Partials       49       49           
Flag Coverage Δ
e2e 83.11% <100.00%> (ø)
unit 83.11% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
@erka
Copy link
Member

erka commented Jan 13, 2026

@saleemrashid What a bug...

Could you please merge this PR into your branch?

@dangra
Copy link

dangra commented Jan 13, 2026

Could you please merge this PR into your branch?

@erka : Saleem is away until later today. I merged it in case we can save another sun cycle :) thanks!

erka and others added 2 commits January 13, 2026 14:42
Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
@erka
Copy link
Member

erka commented Jan 13, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a bug where a closed event channel from a multiprovider would cause an infinite loop of zero-value events. The fix involves checking the second return value from the channel receive operation to detect when the channel is closed, and the associated goroutine is now only started if the provider is an EventHandler. A comprehensive test case is added to verify this fix. My main feedback is to maintain consistency in the testing style by avoiding the introduction of a new testing library and instead using the existing helper functions and standard library assertions.

Copy link
Member

@erka erka left a comment

Choose a reason for hiding this comment

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

@erka
Copy link
Member

erka commented Jan 13, 2026

@toddbaert @sahidvelji could you please take a look?

@beeme1mr beeme1mr merged commit e07a5e4 into open-feature:main Jan 13, 2026
6 checks passed
@dangra dangra deleted the saleem-fix-multiprovider branch January 14, 2026 15:45
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.

4 participants