Skip to content

Commit c7a6681

Browse files
committed
Call initialization from context change if not initialized
1 parent 081b53e commit c7a6681

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/web/src/open-feature.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,14 @@ export class OpenFeatureAPI
385385
oldContext: EvaluationContext,
386386
newContext: EvaluationContext,
387387
): Promise<void> {
388+
// if the provider hasn't initialized yet, and isn't actively initializing, initialize instead of running context change handler
389+
// the provider will be in this state if the user requested delayed initialization until the first context change
390+
const initializationPromise = this.initializeProviderForDomain(wrapper, domain);
391+
if (initializationPromise) {
392+
await initializationPromise;
393+
return;
394+
}
395+
388396
// this should always be set according to the typings, but let's be defensive considering JS
389397
const providerName = wrapper.provider?.metadata?.name || 'unnamed-provider';
390398

0 commit comments

Comments
 (0)