Closed clintonb closed 3 years ago
Hi @clintonb ,
Thank you for the reporting.
Can you share you NODE version and the full initialisation code (without SDK key)?
Do you use any proxy settings?
Thanks, Endre
Node v14.16.1
const config = require('config'); // node-config
const configcat = require('configcat-node');
const logger = require('../logger'); // winston
class FeatureFlag {
static getClient() {
return configcat.createClient(config.get('configCatKey'), {logger});
}
/**
* Returns the value of a feature flag or setting based on its key.
*
* @param {String} key Flag name/identifier
* @param {Boolean} defaultValue Default flag value (if not found
* @param {String} userId ID of the authenticated user. This can be used for variation targeting.
* @returns {Promise<Boolean>}
*/
static async isEnabled(key, defaultValue = false, userId = undefined) {
const userObject = userId ? {identifier: userId.toString()} : undefined;
return FeatureFlag.getClient().getValueAsync(key, defaultValue, userObject);
}
}
module.exports = FeatureFlag;
Hi @clintonb
Thanks the code, I investigated your issue and identify these possible failures:
Based on the error message (connect ECONNREFUSED 127.0.0.1:443) it looks like versioning problem and it is known issue about the got
-> https://github.com/sindresorhus/got/issues/1572
If you use the mentioned code in production and you have heavy load in your system it can occur similar issue because you create an configcat client every time when invoke isEnabled function. I recommend to apply any singleton solution to take advantage of internal caching mechanisms.
...
class FeatureFlag {
static instance;
static getClient() {
if (!this.instance) {
this.instance = configcat.createClient(config.get('configCatKey'), {logger});
}
return this.instance;
}
...
Meanwhile I created a new release (6.5.8) with the previous got version, may you try with this in your application.
6.5.8 works. Thanks!
Describe the bug
v6.5.7 is broken. After upgrading, and changing no config settings, my attempts to check flags fail:
Downgrading to 6.5.6 works. This issue was most likely a result of #32.