docs: add ADR 0010 to disable default polling for static-context providers#69
docs: add ADR 0010 to disable default polling for static-context providers#69jonathannorris wants to merge 5 commits intomainfrom
Conversation
Summary of ChangesHello, 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 introduces a significant change to how static-context providers refresh feature flag evaluations. It proposes disabling default timer-based polling in favor of event-driven mechanisms, such as initialization, context changes, app foreground/page visibility, and Server-Sent Events (SSE) pushes. This aims to enhance sticky bucketing consistency, reduce resource consumption on client devices, and align the OpenFeature Protocol with common practices observed in leading vendor SDKs. Highlights
Using Gemini Code AssistThe 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
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 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces ADR 0010, which proposes to disable default timer-based polling for static-context providers in favor of event-driven updates. This is a well-reasoned and detailed proposal that aligns with common industry practices. My review includes a few suggestions to improve the accuracy and completeness of the ADR: correcting a potentially broken link to another ADR, fixing an incorrect API name for watchOS foreground detection, and recommending that a more concrete migration strategy for the proposed breaking change be included directly in the ADR.
service/adrs/0010-disable-default-polling-for-static-context-providers.md
Show resolved
Hide resolved
service/adrs/0010-disable-default-polling-for-static-context-providers.md
Show resolved
Hide resolved
service/adrs/0010-disable-default-polling-for-static-context-providers.md
Outdated
Show resolved
Hide resolved
toddbaert
left a comment
There was a problem hiding this comment.
I'm good with this, but interested in what @beeme1mr @lukas-reining @thomaspoignant think.
lukas-reining
left a comment
There was a problem hiding this comment.
Approving with some comments.
|
|
||
| Timer-based polling is problematic for static-context providers for two reasons: | ||
|
|
||
| 1. **Sticky bucketing** — polling causes flag values to change mid-session, breaking the expectation that a user sees consistent behavior throughout a session. Most platforms expect feature flag bucketing to remain sticky for a user's whole session. Changing flag values mid-session can cause UI flicker, inconsistent experiences, and breaks experiment integrity. |
There was a problem hiding this comment.
Why does polling change the bucketing?
Wouldn't we assume the bucketing to be consistent throughout all reloads of an app during the experiment? The polling is noting else than a reload to me.
There was a problem hiding this comment.
While bucketing is generally deterministic, there are cases where time-based rules (commonly used in rollouts) would get triggered by polling where they would generally stay consistent between sessions if polling wasn't used. With 30s polling, those changes get picked up mid-session while the user is actively using the app, which can cause the experience to shift unexpectedly. With foreground-only refresh, changes are picked up at a natural transition point when the user returns to the app. SSE-based pushes as discussed in ADR-0008 would also trigger changes, but those are explicit server-initiated notifications rather than the client blindly re-fetching on a timer.
service/adrs/0010-disable-default-polling-for-static-context-providers.md
Show resolved
Hide resolved
|
|
||
| 2. **Context change** — when `onContextChange` is invoked (e.g., user switch, logout), the provider re-fetches bulk evaluations for the new context. This is already handled by existing provider implementations. | ||
|
|
||
| 3. **App foreground / page visibility** — when the application returns from the background or the page becomes visible, the provider should re-fetch bulk evaluations. This ensures values are fresh when the user returns without requiring continuous polling. |
There was a problem hiding this comment.
Would't this bring back the flickering described above?
First the old values would be there until the request has finished.
There was a problem hiding this comment.
yea there's still a potential for the values to change on foreground, but in most real-world cases it's very unlikely there is any change when the app is foregrounded since feature flag changes are fairly infrequent. The difference is also that it happens at a natural transition point when the user returns to the app rather than unpredictably while they're actively using it. Users already expect the app to refresh when they come back to it. With polling, the values can change mid-interaction which is more disruptive.
service/adrs/0010-disable-default-polling-for-static-context-providers.md
Show resolved
Hide resolved
… providers Replace default timer-based polling with trigger-based refresh (initialization, context change, app foreground, SSE push). Closes #68. Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
… ADR 0010 Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
4f82864 to
c987f3d
Compare
Breaking provider change is acceptable since OFREP providers are all sub-v1. Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
…R 0010 Foreground re-fetch cooldown is unnecessary since ETag/304 handles redundant requests. Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
|
/gemini review |
There was a problem hiding this comment.
Pull request overview
Adds a new Architecture Decision Record (ADR) documenting a shift away from default timer-based polling for OFREP static-context providers, favoring event-driven refresh (init/context change/foreground/SSE), while keeping polling as opt-in.
Changes:
- Introduces ADR-0010 specifying that default timer polling should be disabled for static-context providers.
- Defines recommended event-driven refresh triggers (initialization, context change, foreground/visibility, SSE push).
- Documents interactions with SSE (
changeDetectionmodes) and conditional refresh via ETag.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| Static-context providers should not poll on a fixed timer by default. Instead, providers should re-fetch bulk evaluations based on event-driven triggers: | ||
|
|
||
| 1. **Initialization** — as defined in [ADR-0009](0009-localStorageForStaticContextProviders.md), providers fetch bulk evaluations during initialization (or load from cache and refresh in the background). |
|
|
||
| 4. **SSE push** — when an SSE `refetchEvaluation` event is received (as defined in [ADR-0008](0008-sse-for-bulk-evaluation-changes.md)), the provider re-fetches bulk evaluations. This provides real-time updates when the server supports it. | ||
|
|
||
| Timer-based polling should remain available as an opt-in configuration for applications that want it, but the default poll interval should be disabled (0 or negative value). |
| - `polling`: Opt-in timer-based polling for applications that want it. When this mode is selected, the provider should still re-fetch on foreground in addition to polling. | ||
| - `none`: No background refresh. Rely solely on initialization and `onContextChange` calls. | ||
|
|
||
| This ADR changes the behavior within the `sse` default mode: instead of falling back to timer-based polling when SSE is unavailable, the provider relies on foreground refresh and explicit context change triggers. Timer-based polling is only used when explicitly configured via the `polling` mode. |
| All re-fetch triggers (foreground, SSE push, context change, opt-in polling) should use the stored `ETag` with `If-None-Match` for bandwidth efficiency, except when performing a full unconditional re-fetch after SSE inactivity (as specified in [ADR-0008](0008-sse-for-bulk-evaluation-changes.md)). | ||
|
|
| - Foreground detection should be implemented behind a platform abstraction so it can be tested and swapped | ||
| - The existing `pollInterval` configuration should default to `0` (disabled) instead of the current positive values (JS: 30000ms, Swift: 30s, Kotlin: 5min). Applications can opt into polling by setting a positive value. | ||
| - This ADR supersedes the default polling behavior established in [ADR-0005](0005-polling-for-bulk-evaluation-changes.md) for static-context providers only. ADR-0005 remains valid for the polling protocol mechanism itself and for dynamic-context (server-side) providers. | ||
| - Providers should emit `PROVIDER_CONFIGURATION_CHANGED` when a foreground re-fetch returns updated flag values |
|
|
||
| - [ADR-0005: Polling for bulk evaluation changes](0005-polling-for-bulk-evaluation-changes.md) | ||
| - [ADR-0008: SSE for bulk evaluation changes](0008-sse-for-bulk-evaluation-changes.md) | ||
| - [ADR-0009: Local storage for static-context providers](0009-localStorageForStaticContextProviders.md) |
There was a problem hiding this comment.
Code Review
This pull request introduces ADR-0010, which proposes disabling default timer-based polling for static-context providers in favor of event-driven triggers such as application foregrounding and SSE. The review feedback identifies a contradiction regarding 'unconditional' re-fetches when SSE is unavailable, which conflicts with the ETag revalidation strategy, and notes an inconsistency in event naming compared to existing project guidelines.
|
|
||
| On foreground, if the provider has an active SSE connection, no re-fetch is needed as the SSE connection handles change detection. If the SSE connection was closed during inactivity (as described in [ADR-0008](0008-sse-for-bulk-evaluation-changes.md)), the provider should reconnect and perform a full unconditional re-fetch. | ||
|
|
||
| If SSE is not configured or not supported by the server, the provider should re-fetch on foreground unconditionally. |
There was a problem hiding this comment.
The term 'unconditionally' here contradicts the 'ETag revalidation' section on line 68. If SSE is not supported, the foreground trigger should still use conditional requests (ETag) to save bandwidth, as it is not subject to the 'SSE inactivity' exception defined in ADR-0008.
| If SSE is not configured or not supported by the server, the provider should re-fetch on foreground unconditionally. | |
| If SSE is not configured or not supported by the server, the provider should re-fetch on foreground. |
| - Foreground detection should be implemented behind a platform abstraction so it can be tested and swapped | ||
| - The existing `pollInterval` configuration should default to `0` (disabled) instead of the current positive values (JS: 30000ms, Swift: 30s, Kotlin: 5min). Applications can opt into polling by setting a positive value. | ||
| - This ADR supersedes the default polling behavior established in [ADR-0005](0005-polling-for-bulk-evaluation-changes.md) for static-context providers only. ADR-0005 remains valid for the polling protocol mechanism itself and for dynamic-context (server-side) providers. | ||
| - Providers should emit `PROVIDER_CONFIGURATION_CHANGED` when a foreground re-fetch returns updated flag values |
There was a problem hiding this comment.
The event name PROVIDER_CONFIGURATION_CHANGED is inconsistent with the existing documentation in guideline/static-context-provider.md (line 83), which uses ConfigurationChanged. While PROVIDER_CONFIGURATION_CHANGED is the official OpenFeature specification constant, it is better to maintain consistency with the other guidelines in this repository.
| - Providers should emit `PROVIDER_CONFIGURATION_CHANGED` when a foreground re-fetch returns updated flag values | |
| - Providers should emit `ConfigurationChanged` when a foreground re-fetch returns updated flag values |
Summary
Motivation
Current OFREP static-context providers poll on a fixed timer by default (JS: 30s, Swift: 30s, Kotlin: 5min). This breaks sticky bucketing expectations and wastes resources on mobile. The majority of vendor SDKs (DevCycle, LaunchDarkly, Statsig, Eppo) do not use timer-based polling as the default client-side refresh mechanism.
See the vendor comparison table in the issue for details.
Notes
Related Issues
Closes #68