refactor: simplify getting initializationState#1202
Conversation
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-client-sdk-common size report |
|
@launchdarkly/browser size report |
a5d4d5f to
85fce1b
Compare
|
@cursor review |
85fce1b to
d710974
Compare
d710974 to
2da69a5
Compare
|
@cursor review |
| function notifyContextSubscribers() { | ||
| const newContext = baseClient.getContext(); | ||
| if (newContext) { | ||
| subscribers.forEach((cb) => cb(newContext)); |
There was a problem hiding this comment.
Should these be ran in another turn of the event loop? Or do we want them inline.
Basically do you want the result of the identify before the context notification, or after?
There was a problem hiding this comment.
I think we can only notify after the identify promise is resolved... I don't think we can really inline this as we are using the browser sdk identify method.
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
We should notify the context change before notifying the initialization result
This PR will align our initialization status handling closer to the base browser sdk by:
initializingandunknownstate which should get rid of one extra state dispatch on initializationNote
Medium Risk
Medium risk because it changes the public initialization-state contract (dropping
unknown) and alters server-side/noop client behavior to return a failure + error, which may affect consumers that previously treated these as non-error states.Overview
Initialization state handling is simplified by removing the
unknownstate fromInitializedState/InitializationStatusand defaulting new clients and test harnesses toinitializing.createClient()behavior changes:start()now uses explicit idempotency guards (startCalled/startNotified) and triggers a one-timeonContextChangenotification after the first successfulstart()completion; the server-side/noop client now reportsfailedwith a concretegetInitializationError()message instead of returningunknown/undefined.Tests and the migration docs are updated to reflect the new state model and server-side error semantics.
Written by Cursor Bugbot for commit 86d0919. This will update automatically on new commits. Configure here.