Skip to content

FileDataSource no longer emits flag changes on file updates #310

@fhawkes

Description

@fhawkes

Describe the bug
The FileDataSource no longer correctly tracks streaming (realtime) changes to flags when updating the json file on disk.

To reproduce
Create a LD client utilizing the FileDataSource with autoUpdate turned on and pointing to one json file on disk that looks similar to this

{
    "flagValues": {
        "coolFlag": false
    }
}

While creating the client subscribe to flag changes like so

this.client.on('update', (flagChange) => {
	// Expecting the flag change to be emitted, it is not
    logger.trace(`LaunchDarkly flag changed ${flagChange.key}.`);
});

Expected behavior
When changing the value of an existing flag in the json file, I expect events to be emitted by the LD client informing us about flag changes.

Logs
If applicable, add any log output related to your problem.

SDK version
@launchdarkly/node-server-sdk 9.0.2

Language version, developer tools
Node v18.17.1

OS/platform
macOS 13.5.2

Additional context
I did some digging and it appears that in the most recent version of this package we hardcode the flag version to always be 1 here

This prevents the DataSourceUpdates code here from ever detecting a change with the flag because is specifically looks at the version which will always be equal.

if (newValue && oldValue && newValue.version <= oldValue.version) {

In previous versions of the sdk that were no typescript the version flag was not included. We could pull the version in from the the existing flag in the feature store if it exists, but I didn't see a clean way to fetch that value at a glance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: shared/sdk-serverLabel for issues affecting the shared/sdk-server package.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions