diff --git a/package.json b/package.json index 6db06418a0..63d56eda3e 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ "stoppable": "^1.1.0", "ts-toolbelt": "^9.6.0", "type-is": "^1.6.18", - "unleash-client": "3.16.1", + "unleash-client": "3.18.0", "use-deep-compare-effect": "^1.8.1", "uuid": "^9.0.0" }, diff --git a/src/lib/services/proxy-service.ts b/src/lib/services/proxy-service.ts index 5dd9157a4a..2f84d32b51 100644 --- a/src/lib/services/proxy-service.ts +++ b/src/lib/services/proxy-service.ts @@ -5,7 +5,6 @@ import ApiUser from '../types/api-user'; import { Context, InMemStorageProvider, - startUnleash, Unleash, UnleashEvents, } from 'unleash-client'; @@ -134,7 +133,7 @@ export class ProxyService { token, ); - const client = await startUnleash({ + const client = new Unleash({ appName: 'proxy', url: 'unused', storageProvider: new InMemStorageProvider(), @@ -146,6 +145,8 @@ export class ProxyService { this.logger.error(error); }); + await client.start(); + return client; } diff --git a/src/lib/util/feature-evaluator/repository/index.ts b/src/lib/util/feature-evaluator/repository/index.ts index ee4e9433ae..bba8bc1341 100644 --- a/src/lib/util/feature-evaluator/repository/index.ts +++ b/src/lib/util/feature-evaluator/repository/index.ts @@ -2,6 +2,8 @@ import { ClientFeaturesResponse, FeatureInterface } from '../feature'; import { BootstrapProvider } from './bootstrap-provider'; import { StorageProvider } from './storage-provider'; import { Segment } from '../strategy/strategy'; +import { EventEmitter } from 'stream'; +import { UnleashEvents } from 'unleash-client'; export interface RepositoryInterface { getToggle(name: string): FeatureInterface; @@ -20,7 +22,7 @@ interface FeatureToggleData { [key: string]: FeatureInterface; } -export default class Repository { +export default class Repository extends EventEmitter { private timer: NodeJS.Timer | undefined; private appName: string; @@ -38,14 +40,16 @@ export default class Repository { bootstrapProvider, storageProvider, }: RepositoryOptions) { + super(); this.appName = appName; this.bootstrapProvider = bootstrapProvider; this.storageProvider = storageProvider; this.segments = new Map(); } - start(): Promise { - return this.loadBootstrap(); + async start(): Promise { + await this.loadBootstrap(); + process.nextTick(() => this.emit(UnleashEvents.Ready)); } createSegmentLookup(segments: Segment[] | undefined): Map { diff --git a/src/lib/util/offline-unleash-client.test.ts b/src/lib/util/offline-unleash-client.test.ts index c7ec7f3030..607cbe729b 100644 --- a/src/lib/util/offline-unleash-client.test.ts +++ b/src/lib/util/offline-unleash-client.test.ts @@ -22,6 +22,7 @@ export const offlineUnleashClientNode = async ({ appName: context.appName, disableMetrics: true, refreshInterval: 0, + skipInstanceCountWarning: true, url: 'not-needed', storageProvider: new InMemStorageProviderNode(), bootstrap: { diff --git a/yarn.lock b/yarn.lock index 8990e77a80..3ec271759f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3659,7 +3659,7 @@ interpret@^2.2.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== -ip@^1.1.5, ip@^1.1.8: +ip@^1.1.8: version "1.1.8" resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48" integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg== @@ -6730,15 +6730,15 @@ universalify@^0.1.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== -unleash-client@3.16.1: - version "3.16.1" - resolved "https://registry.yarnpkg.com/unleash-client/-/unleash-client-3.16.1.tgz#81eede77202789eb20eda126d9c7747567bb0628" - integrity sha512-N8c0b2B8LFjfDErCJYMZfAPRZiRRGYFZ0aBLRMnpA1K5iFm/I/TH91UgAGsylOsWngnUKXTST7kYeDgK1Aydug== +unleash-client@3.18.0: + version "3.18.0" + resolved "https://registry.yarnpkg.com/unleash-client/-/unleash-client-3.18.0.tgz#4ea32b38e9b7518ef8816dcaac884a8eb32fea25" + integrity sha512-BCq/m59XgrfgfI05wxdY1n3zAPeAvMMIKkHhKzKgObjRz1ucwPYcPTB3lQTU0foqP7AuieDRHsJxqBpkCCqbCw== dependencies: - ip "^1.1.5" + ip "^1.1.8" make-fetch-happen "^10.2.1" murmurhash3js "^3.0.1" - semver "^7.3.5" + semver "^7.3.8" unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0"