feat: implement remote configuration caching mechanism#4606
Conversation
|
✨ Fix all issues with BitsAI or with Cursor
|
|
|
||
| const cacheResult = configurationCache.read() | ||
|
|
||
| metrics.increment('cache', CACHE_STATUS_TO_METRIC_MAP[cacheResult.status]) |
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
8a5af9b to
5bef505
Compare
| }, | ||
| }) | ||
| .withBody(html`<span id="version">123</span>`) | ||
| .withHead(html`<span id="version">123</span>`) |
There was a problem hiding this comment.
I updated these tests using withHead so that they pass, but there’s an issue here that we should definitely address later
Remote Configuration currently supports dynamic options, one of which is dom. If we use synchronous bundle setup and Remote Configuration is loaded from the cache immediately, this strategy will always fail because SDK initialization happens before the DOM is available
There was a problem hiding this comment.
That's a good point, but it might break existing customer setup if we don't address this now, no?
We can change the test, but we can't change our customer setup
There was a problem hiding this comment.
It seems like it's not something we should solve immediately because currently remote config is only available for SSI clients and from what I know they have hardcoded v6 version and they can't update on their own until we update the injector
| /* The background fetch on the initial page load writes the remote configuration into localStorage; | ||
| * reloading lets the SDK pick it up synchronously on the next init(). |
There was a problem hiding this comment.
💬 suggestion: I think with your change, all the test are now relying on the config being cached and we don't test that the remote config works properly even without cache.
I would rather keep waitForRemoteConfigurationToBeApplied as before and add a separate test specifically for the caching mechanism.
Motivation
Support remote configuration caching mechanism according to the RFC
Changes
The remote configuration is no longer awaited during
DD_RUM.initit is now read synchronously from a versioned localStorage cache (dd_rc_<remoteConfigurationId>) and applied on the same page load. A background fetch always runs in parallel and refreshes the cache for the next page load, so updates roll out one load late but startup is unblocked. Cache outcomes (hit/miss/error) and fetch outcomes (success/failure) are reported via the existing telemetry metrics. Unit tests cover the new cache module and the read/apply/fetch flow; the e2e scenarios were rewritten to wait for the cache to be populated and reload the page before asserting.Test instructions
remote-config.jsonfile to sandbox directoryDD_RUM.initaddingremoteConfigurationId: 'remote-config-test',remoteConfigurationProxy: '/remote-config.json'DD_RUM.getInitConfiguration()returns initial configuration on the first page loadDD_RUM.getInitConfiguration()returns remote configuration on the second page loadChecklist