Skip to content

Commit 151a6cf

Browse files
committed
Call initialization from context change if not initialized
1 parent d623b7b commit 151a6cf

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
@@ -389,6 +389,14 @@ export class OpenFeatureAPI
389389
const providerName = wrapper.provider?.metadata?.name || 'unnamed-provider';
390390

391391
try {
392+
// if the provider hasn't initialized yet, and isn't actively initializing, initialize instead of running context change handler
393+
// the provider will be in this state if the user requested delayed initialization until the first context change
394+
const initializationPromise = this.initializeProviderForDomain(wrapper, domain);
395+
if (initializationPromise) {
396+
await initializationPromise;
397+
return;
398+
}
399+
392400
if (typeof wrapper.provider.onContextChange === 'function') {
393401
const maybePromise = wrapper.provider.onContextChange(oldContext, newContext);
394402

0 commit comments

Comments
 (0)