Skip to content

[BUG] Memory leak after destroying angular application #1218

@MillerSvt

Description

@MillerSvt

Observed behavior

We have multiple angular applications per page, and each have their own feature flags. We use web-sdk, and implement RestClient with using Angular HttpClient. Then we create OpenFeatureClient like this:

        {
            provide: dcoFeatureFlagClient,
            useFactory: async (): Promise<Client> => {
                const restClient = new OpenFeatureRestClient(url); // here is HttpClient inside
                const provider = new FeatureToggleProvider(restClient);
                const context = await contextFactory();

                return OpenFeature.setProvider(provider).getClient(context);
            },
        },

This creates some unexpected behavior:

  1. All Angular applications, uses the same HttpClient instance (from last created application).
  2. HttpClient and all its dependencies does not cleaned by GC, and still persists in memory heap dump until call globalThis[Symbol(@openfeature/js-sdk/api)] = null.
  3. After destroying last created application, others cannot retrieve any feature flags, because HttpClient from last created application, that used by all applications is destroyed, and it throws NG0205 error.

Expected Behavior

DO NOT create global OpenFeature instance in globalThis object. Add ability to create separate instances of OpenFeature API for each applications.

Steps to reproduce

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions