Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
This repository was archived by the owner on May 30, 2024. It is now read-only.

Error when updating TestData when calling ifMatch  #258

@LiamMorrow

Description

@LiamMorrow

Is this a support request?
No

Describe the bug
When using ifMatch on TestData, there is a circular JSON reference error when calling the update method

To reproduce

const launchDarklyClient = ld.init('not a real key', { updateProcessor: testData, sendEvents: false })
const variationForMatch = testData.flag(featureFlagKey).ifMatch('someCustomKey', 'someKeyValue').thenReturn(false)
testData.update(variationForMatch)

Expected behavior
No error

Logs

TypeError: Converting circular structure to JSON
        --> starting at object with constructor 'Array'
        |     index 0 -> object with constructor 'TestDataRuleBuilder'
        |     property '_flagBuilder' -> object with constructor 'TestDataFlagBuilder'
        --- property '_rules' closes the circle
        at JSON.stringify (<anonymous>)
        at TestDataFlagBuilder.Object.<anonymous>.TestDataFlagBuilder.copy (../node_modules/launchdarkly-node-server-sdk/test_data.js:101:53)
        at Function.TestData.td.update (../node_modules/launchdarkly-node-server-sdk/test_data.js:58:58)

SDK version
6.4.2

Language version, developer tools
Typescript/node/jest

OS/platform
All dev platforms

Additional context
Seems to be a circular ref between the rules and the data rule builder

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions