🐛 collect feature flag evaluations before rum start in a map instead of a buffer#4469
Draft
BenoitZugmeyer wants to merge 1 commit intov7from
Draft
🐛 collect feature flag evaluations before rum start in a map instead of a buffer#4469BenoitZugmeyer wants to merge 1 commit intov7from
BenoitZugmeyer wants to merge 1 commit intov7from
Conversation
…of a buffer Previously, `addFeatureFlagEvaluation` calls made before `startRum` were buffered and replayed after init. This caused the `BoundedBuffer` limit to be reached when many flags were evaluated early, silently dropping other buffered calls (e.g. `setUser`). Instead, pre-start evaluations are now collected into a `FeatureFlagCollection` (a `Map<string, ContextValue>`) and passed to `startFeatureFlagContexts`, which seeds the first view's context with it. Subsequent views start with an empty collection as before. This trades per-evaluation ordering for reliability.
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
✨ Fix all issues with BitsAI or with Cursor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When
addFeatureFlagEvaluationis called many times beforeinit()or before the SDKfinishes starting, the pre-start buffer (
BoundedBuffer) can fill up and silently dropsubsequent calls, including important ones like
setUserorsetGlobalContext.Changes
addFeatureFlagEvaluationcalls are now accumulated in aFeatureFlagContext(
Map<string, ContextValue>) instead of the sharedBoundedBuffer. Only the last valueper key is kept (last write wins).
startFeatureFlagContextsand seeded into the firstview's context when RUM starts. Subsequent views start with an empty context as before.
Trade-off: individual pre-start evaluation calls are no longer replayed in order — only the
final value per key reaches the first view. This is acceptable since overwriting a key before
start is uncommon, and reliability (not silently dropping
setUser) takes priority.Test instructions
DD_RUM.init(), callDD_RUM.addFeatureFlagEvaluation('my-flag', true)many times (more than the buffer limit, i.e. > 10 000 times).
DD_RUM.setUser({ id: 'test-user' })and thenDD_RUM.init(...).feature_flags: { "my-flag": true }and that the user context (
usr.id: "test-user") is correctly set on events.Checklist