Repository navigation
fix: Warn when offline mode skips the override source, and ignore snapshots after close - #2133
kinyoklion wants to merge 1 commit into
Conversation
…pshots after close When the client is offline and an override source is configured, the source is still not built or started, and the SDK now logs a warning that no overrides are served. The overrides option documents that a configuration error in the source is not reported offline. Closing the client closes the override sink before the source, so a snapshot that a custom source supplies after the client is closed no longer changes the layer or notifies the application.
|
bugbot review |
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c07a82b. Configure here.
Summary
Two follow-ups from the review of the same code in the .NET port (launchdarkly/dotnet-core#364).
Offline mode. When the client is offline, a configured override source is not built or started, and that stays so. Nothing said so before: an application running offline with overrides saw default values and no explanation, and a configuration error in the source went unreported. The SDK now logs a warning once, at construction:
Offline mode is enabled; the override source is not started and no overrides are served. Theoverridesoption documents that the source is not built or started offline, that no overrides are served, and that a configuration error in the source is not reported then.Snapshots after close.
close()closed the override source, but the sink kept accepting snapshots, so a custom source that supplied one after the client was closed still replaced the layer and sent flag change events to the application. The client now closes the sink before the source. A closed sink ignores a snapshot (logged at debug level) and keeps the layer as it is, so closing sends no change events of its own. The SDK's file-based source stops supplying snapshots when it is closed, so this only matters for a custom source.Tests
Three tests in
LDClientImpl.overrides.test.ts: offline mode logs the warning and never calls the source factory; offline mode without a source logs no override warning; and a snapshot supplied through the sink afterclose()produces no change event and no override. The first and third fail without the change, and each fails again with its fix reverted. The sdk-server suite passes (1562 passed, 7 skipped), and lint and formatting are clean.Opened from termag
SDK-3419
Note
Overview
Offline + overrides. When
offlineis enabled butdataSystem.overridesis set, the SDK still does not build or start the override source (unchanged). It now logs a one-time construction warning: Offline mode is enabled; the override source is not started and no overrides are served, andLDDataSystemOptionsdocuments that behavior. Offline clients without an override source do not get that warning.Shutdown.
OverrideSinkgains aclose()that stops accepting snapshots; latesetOverridescalls are ignored (debug log) and do not update the layer or fire flag-change listeners.LDClientImpl.close()closes the sink before the override source so custom sources that keep pushing after close cannot mutate state post-shutdown.Three tests cover the offline warning, absence of spurious warnings, and post-close snapshot handling.
Reviewed by Cursor Bugbot for commit c07a82b. Bugbot is set up for automated code reviews on this repo. Configure here.