Skip to content

fix: Unsubscribe the provider's listeners on shutdown - #37

Merged
kinyoklion merged 3 commits into
devin/1788360613-ruby-zero-start-waitfrom
devin/1788360667-ruby-event-dedup
Oct 2, 2026
Merged

kinyoklion merged 3 commits into
devin/1788360613-ruby-zero-start-waitfrom
devin/1788360667-ruby-event-dedup

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

The provider's data source status and flag change listeners stayed registered on the LaunchDarkly client after shutdown, so a provider which the OpenFeature SDK had already replaced could still emit events. They are now removed before the client is closed.

Event deduplication and the events emitted after a failed initialization, which this PR previously carried, now live in #36 instead; this branch has been merged with that one and keeps only the shutdown change. Review #36 first.

Found during the weekly OpenFeature provider audit.

Implementation details

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

None.

Describe the solution you've provided

The listeners the constructor registers are kept on the provider so that shutdown can pass them to remove_listener on the data source status provider and the flag tracker before closing the client.

Describe alternatives you've considered

Relying on close alone: the LaunchDarkly client stops notifying listeners once it is closed, but the provider is the owner of those subscriptions and a closed client is not a guarantee the OpenFeature SDK makes about a replaced provider.

Additional context

Testing: bundle exec rspec (83 examples) and bundle exec rubocop on Ruby 3.4.5. The shutdown spec now asserts both listeners are removed as well as the client being closed.

Link to Devin session: https://app.devin.ai/sessions/fe1eb757fe694ef79f3d09f6307d4b47
Open in Devin Desktop: https://app.devin.ai/desktop/session/fe1eb757fe694ef79f3d09f6307d4b47?variant=devin
Requested by: @kinyoklion

@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot added the devin-pr PRs created by Devin label Sep 2, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

@cursor review

@kinyoklion
kinyoklion marked this pull request as ready for review September 29, 2026 22:44
@kinyoklion
kinyoklion requested a review from a team as a code owner September 29, 2026 22:44

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e2f07de. Configure here.

Comment thread lib/ldclient-openfeature/provider.rb Outdated
devin-ai-integration Bot and others added 2 commits September 29, 2026 22:56
A client which fails to initialize can still connect afterward, so the status and flag listeners are now registered regardless of the outcome.

Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
…-wait' into devin/1788360667-ruby-event-dedup

Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>

# Conflicts:
#	README.md
#	lib/ldclient-openfeature/impl/event_listeners.rb
#	lib/ldclient-openfeature/provider.rb
@devin-ai-integration devin-ai-integration Bot changed the title fix: Do not emit duplicate provider events fix: Unsubscribe the provider's listeners on shutdown Sep 29, 2026
@kinyoklion
kinyoklion merged commit c6e8ce6 into devin/1788360613-ruby-zero-start-wait Oct 2, 2026
6 checks passed
@kinyoklion
kinyoklion deleted the devin/1788360667-ruby-event-dedup branch October 2, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devin-pr PRs created by Devin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants