Reentrant provider events reach client callbacks out of order
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with dispatch_provider_event in lib/open_feature/sdk/configuration.rb, where global handlers run before client handlers and can re-dispatch reentrantly. Run the reproduction from the issue both ways (default and ready_stale) to confirm the wrong order. Done means both commands print the expected order, and deferred events keep their emission order and are dropped when a provider is shut down or replaced. The author says a local fix is already in preparation, so check with them before starting.
由索引模型根据 Issue 内容生成。
描述
Problem
Applications tracking provider availability through client event handlers can receive PROVIDER_READY followed by PROVIDER_ERROR after a provider has recovered. A similar sequence delivers PROVIDER_STALE before the preceding PROVIDER_READY.
This happens when a global event handler synchronously emits another provider event. The nested event reaches client handlers before the original event does. It reproduces with openfeature-sdk 0.5.1, 0.6.5, and current main at e602d1559af71324dcc11cc45462ba47075f32f9, using Ruby 4.0.1.
Related: #300 tracks provider lifecycle event ownership, and #137 tracks broader concurrency. This reproduction uses an already initialized provider and manually emitted events, so it also occurs independently of synthetic initialization events.
Reproduction
Save this as repro.rb and run it in an environment with openfeature-sdk installed. No Datadog dependency, network requests, or background threads are needed.
require "open_feature/sdk"
class EmittingProvider < OpenFeature::SDK::Provider::InMemoryProvider
include OpenFeature::SDK::Provider::EventEmitter
end
configuration = OpenFeature::SDK.configuration
provider = EmittingProvider.new
configuration.set_provider_and_wait(provider)
provider.emit_event(OpenFeature::SDK::ProviderEvent::PROVIDER_STALE)
client = OpenFeature::SDK::Client.new(provider: provider)
events = []
first, following = (ARGV.first == "ready_stale") ? [:READY, :STALE] : [:ERROR, :READY]
first_event = OpenFeature::SDK::ProviderEvent.const_get("PROVIDER_#{first}")
following_event = OpenFeature::SDK::ProviderEvent.const_get("PROVIDER_#{following}")
configuration.add_handler(first_event, ->(_) { provider.emit_event(following_event) })
client.add_handler(first_event, ->(_) { events << first })
client.add_handler(following_event, ->(_) { events << following })
events.clear # Ignore immediate callbacks during handler registration.
provider.emit_event(first_event)
puts "Expected: #{[first, following].inspect}; actual: #{events.inspect}"
| Command | Expected callbacks | Actual callbacks |
|---|---|---|
ruby repro.rb |
[:ERROR, :READY] |
[:READY, :ERROR] |
ruby repro.rb ready_stale |
[:READY, :STALE] |
[:STALE, :READY] |
Proposed direction
In Configuration#dispatch_provider_event, state is updated before global handlers and then client handlers run. A global handler can recursively dispatch another event before the original client callbacks finish.
Finish delivery of the current event to global and client handlers before dispatching events emitted reentrantly on the same thread. Deferred events should preserve their emission order and payload, and must be invalidated when the associated provider registration ends through shutdown or replacement. This need not impose total ordering across independent threads.
A local fix and SDK-native regression tests are in preparation. The downstream report that led to this reproduction is DataDog/dd-trace-rb#6418.
- 主要语言
- Ruby
- 星标
- 43
- 派生
- 18
- 平均合并
- 1 天 5 小时
- 30 天内合并 PR
- 23
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
open-feature/ruby-sdk 的其他 Issue
-
OpenFeature specification v0.9.0
难度 5/5 一周以上 新手友好度 25/100
open-feature/ruby-sdk#300 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 52/100
open-feature/ruby-sdk#297 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
open-feature/ruby-sdk#137 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 15/100
open-feature/ruby-sdk#4 ·
维护者通常 1 天内回复
查看 open-feature/ruby-sdk 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
Dialog: clicking the panel's inner padding closes it (backdropClick matches the <dialog> itself)未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
Homebrew/homebrew-cask#295450 ·
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 72/100
TheOdinProject/curriculum#31479 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100