Unleash/unleash-client-node

Breaking change between 3.4.0 and 3.7.1?

digitalsadhu opened this issue · 3 comments

Somewhere between 3.4.0 and 3.7.1 something broke for us. Pinning to 3.4.0 fixed it.

TypeError: normalizedValue is not a function
    at MultiVariantAbTestingStrategy.getVariation (/home/node/src/node_modules/@finn-no/express-unleash-middleware/lib/strategy/multi-variant-ab-testing.js:45:28)
    at ExperimentTracker.getFirstEnabledVariation (/home/node/src/node_modules/@finn-no/express-unleash-middleware/lib/experiment/experiment-tracker.js:97:30)
    at ExperimentTracker.getVariation (/home/node/src/node_modules/@finn-no/express-unleash-middleware/lib/experiment/experiment-tracker.js:84:39)
    at ExperimentTracker.startExperiment (/home/node/src/node_modules/@finn-no/express-unleash-middleware/lib/experiment/experiment-tracker.js:48:32)
    at Object.startExperiment (/home/node/src/node_modules/@finn-no/express-unleash-middleware/lib/index.js:122:39)
    at /home/node/src/src/layouts/frontpage/index.js:151:69
    at Layer.handle [as handle_request] (/home/node/src/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/node/src/node_modules/express/lib/router/route.js:137:13)
    at /home/node/src/node_modules/@finn-no/express-unleash-middleware/lib/index.js:127:13
    at Layer.handle [as handle_request] (/home/node/src/node_modules/express/lib/router/layer.js:95:5)

Looks like it comes from our usage:

const { normalizedValue } = require('unleash-client/lib/strategy/util');

at some point normalizedValue stopped being a function

I think using const normalizedValue = require('unleash-client/lib/strategy/util'); would fix it.

Though this is not actually part of the official API, we did not make a majorVersion release. Be aware that this can break in the future, for instance if we need another internal util function for strategies.


After migrating to airbnb eslint the function was switched to export default rather than an explicit export by name.

Looks like its because of a change to the build output. I had to change it to:

const util = require('unleash-client/lib/strategy/util');

const normalizedValue = util.default;