Coder Social home page Coder Social logo

configcat / node-sdk Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 7.0 1.77 MB

ConfigCat SDK for Node.js. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.

Home Page: https://configcat.com/docs/sdk-reference/node

License: MIT License

TypeScript 96.34% Shell 1.96% JavaScript 1.71%
configcat feature-flags feature-toggles feature-toggle feature-flag node-js nodejs configuration-management configuration typescript

node-sdk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

node-sdk's Issues

JSONConfig is not present. Returning default value: 'false'.

When running configcat in a NodeJS project we get the following console log error:
JSONConfig is not present. Returning default value: 'false'.

Occurs with all methods (getValue, getValueAsync. getAllKeys).
Tried upgrading (were on version 2.2.5, then tried 3.0.0, and also tried 2.4.0).
Do you have any idea what could cause this?
Thanks in advance.

Proxy support

Hi, my service are running behind a firewall which require a proxy to access configure file. Node SDK seems not able to send request over proxy.

6.5.7 cannot retrieve flags or settings

Describe the bug

v6.5.7 is broken. After upgrading, and changing no config settings, my attempts to check flags fail:

2021-08-09T16:15:39.577Z | [error] Failed to download feature flags & settings from ConfigCat. Empty response from API. Error: connect ECONNREFUSED 127.0.0.1:443
2021-08-09T16:15:39.578Z | [info] Double-check your SDK Key on https://app.configcat.com/sdkkey
2021-08-09T16:15:44.495Z | [error] Failed to download feature flags & settings from ConfigCat. Empty response from API. Error: connect ECONNREFUSED 127.0.0.1:443
2021-08-09T16:15:44.495Z | [info] Double-check your SDK Key on https://app.configcat.com/sdkkey
2021-08-09T16:15:44.495Z | [error] JSONConfig is not present. Returning default value: 'false'.

Downgrading to 6.5.6 works. This issue was most likely a result of #32.

Add an `onConfigDownloadFailed` option to the options object

Is your feature request related to a problem? Please describe.

We're using this in our product, but we wanted to have a backup plan in case the ConfigCat service was down. We would like a way to be able to call a function in the event the config download fails.

Describe the solution you'd like

We'd like it if the options supported an onConfigDownloadFailed option, which would be a callback that gets called if the config download fails.

Describe alternatives you've considered

We do have a workaround but it's a bit "hacky". We put a wrapper around the logger's error function, and are checking the error message to see if it contains the string Failed to download feature flags & settings from ConfigCat., which comes from this line in the config-fetcher.

Additional context

I wasn't sure it it made more sense for the option to exist in the configcat/common-js package but I realized the download/error message were happening in this SDK, not the common library.

CORS error on Safari

CORS error happens on Safari on Mac (10.14.2) or iPhone (12.1.4) and fails to load value. On Chrome and Firefox it doesn't.

[Error] FetchEvent.respondWith received an error: TypeError: Request header field Pragma is not allowed by Access-Control-Allow-Headers.
[Error] Fetch API cannot load https://cdn.configcat.com/configuration-files/******/******/config_v2.json.
[Error] Failed to load resource: FetchEvent.respondWith received an error: TypeError: Request header field Pragma is not allowed by Access-Control-Allow-Headers. (config_v2.json, line 0)
[Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'i.statusCode')
	(anonymous function) (5-6d4e00da54cceb61032d.js:1:549939)
	callback (5-6d4e00da54cceb61032d.js:1:835174)
	(anonymous function)
	emit (5-6d4e00da54cceb61032d.js:1:291085)
	onRequestError (5-6d4e00da54cceb61032d.js:1:844228)
	(anonymous function)
	emit (5-6d4e00da54cceb61032d.js:1:291085)
	(anonymous function) (5-6d4e00da54cceb61032d.js:1:855980)
	promiseReactionJob

Offline access for feature alignment with other language SDKs

Is your feature request related to a problem? Please describe.

Can we get the JS (frontend, SSR, Node) SDKs to be feature aligned with other language SDKs?

Specifically offline and local configurations of flags for the purpose of local development or testing?

Describe the solution you'd like

A clear and concise description of what you want to happen.

For the javascript constructors to take an optional "local" configuration.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the feature request here.

For example with PHP SDK it allows for: https://configcat.com/docs/sdk-reference/php/#flag-overrides

SDK gets out of sync ofter running for a couple of days

Describe the bug

We encountered an issue in our production services - after a few days, suddenly the ConfigCat client gets out of sync and
returns old values when calling getValueAsync or getAllValues. When it happens, the client will no longer gets the updated values. There are also no logs when this happens.

We initialize the client as a singleton, and use the default auto polling.

I also talked about this issue couple of weeks ago here configcat/common-js#36 (comment)

Will appreciate your quick help, since this is effecting our production environment.

To reproduce

Reproducing this issue is hard, because it happens after a few days the service is running. Suddenly it gets out of sync, and doesn't get updated values.

Expected behavior

Get the updated values when calling getValueAsync or getAllValues.

SDK version

6.7.1

SDK configuration

Initialization:

let client;

function initialize({ sdkKey }) {
    try {
        client = configcat.createClient(sdkKey);
    } catch (e) {
        throw new Error('Failed initializing the configcat feature control.');
    }
}

function getClient() {
    if (!client) {
        throw new Error('client is not initialized yet.');
    }

    return client;
}

Usage:

const client = getClient();

const user = { ... };

const value = await client.getValueAsync(key, false, user);

Logs

None

Language/Framework version

NodeJs 16.13.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.