Unleash / unleash-proxy-client-js

A browser client that can be used together with the unleash-proxy.
Apache License 2.0
44 stars 46 forks source link

CDN client fails for feature toggle with conditional activation strategy #124

Closed alushnikov closed 1 year ago

alushnikov commented 1 year ago

Describe the bug

CDN client fails when trying obtain feature flag value with conditional activation strategy. Simple standard activation strategies do not have problems.

Steps to reproduce the bug

  1. Set up unleash docker + unleash proxy as per documentation
  2. Create feature toggle with condition. In my case: image
  3. Create a simple html page with

<script src="https://unpkg.com/unleash-proxy-client@latest/build/main.min.js" type="text/javascript"></script>

and js code:

var config = {
      url: "http://localhost:3000/proxy",
      clientKey: "proxy-client-key",
      appName: "test"
  };

vat client = new unleash.UnleashClient(config);
client.updateContext({ hostName: "test.co" });
client.start();

function logFeatureFlag() {
    isTenantEnabled = client.isEnabled("per-tenant-feature");

    console.log({ isTenantEnabled: isTenantEnabled });
};

setInterval(logFeatureFlag, 5000);

Expected behavior

Feature Flag value obtained successfully

Logs, error output, etc.

main.min.js:1 Uncaught TypeError: q.randomFillSync is not a function
    at g (main.min.js:1:2075)
    at j (main.min.js:1:2508)
    at a.generateEventId (main.min.js:1:6730)
    at a.createBaseEvent (main.min.js:1:6944)
    at a.createImpressionEvent (main.min.js:1:6802)
    at f.isEnabled (main.min.js:1:9174)
    at logFeatureFlag (app.js? [sm]:328:1)

Screenshots

image

Additional context

No response

Unleash version

latest

Subscription type

Open source

Hosting type

Self-hosted

SDK information (language and version)

latest, javascript

Tymek commented 1 year ago

Thank you for reporting and sorry for inconvenience 😔. I'll check what's going on. We probably need a polyfill like crypto-browserify/randomfill.

What browser are you using? Is it working fine with previous versions of the package?

alushnikov commented 1 year ago

I'm using Google Chrome Version 107.0.5304.110 (Official Build) (x86_64)

Actually that's the first time I've tried using unleash, so can not confirm if this worked with the previous versions.

kwasniew commented 1 year ago

@alushnikov can you try with the latest beta release: <script src="https://unpkg.com/unleash-proxy-client@2.4.0-beta.1/build/main.min.js" type="text/javascript"></script>