Skip to content

fix: Warn when offline mode skips the override source, and ignore snapshots after close - #2133

Open
kinyoklion wants to merge 1 commit into
mainfrom
rlamb/overrides-node-offline-warning
Open

kinyoklion wants to merge 1 commit into
mainfrom
rlamb/overrides-node-offline-warning

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

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. The overrides option 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 after close() 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 offline is enabled but dataSystem.overrides is 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, and LDDataSystemOptions documents that behavior. Offline clients without an override source do not get that warning.

Shutdown. OverrideSink gains a close() that stops accepting snapshots; late setOverrides calls 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.

…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.
@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@github-actions

Copy link
Copy Markdown
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 32220 bytes
Compressed size limit: 32500
Uncompressed size: 152548 bytes

@github-actions

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25998 bytes
Compressed size limit: 44000
Uncompressed size: 167978 bytes

@github-actions

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 34386 bytes
Compressed size limit: 35000
Uncompressed size: 122562 bytes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@kinyoklion
kinyoklion marked this pull request as ready for review October 29, 2026 21:27
@kinyoklion
kinyoklion requested a review from a team as a code owner October 29, 2026 21:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant