Repository navigation
Conversation
| // Before initialize(), it opens the connection itself. With live updates | ||
| // on, the connection already exists and is reopened below. | ||
| if ( | ||
| !this.pubSubInit && |
There was a problem hiding this comment.
[P2] Defer feedback startup whenever the client is stopped
When an anonymous client with enableLiveFlagUpdates: true is initialized and then stopped, stop() closes the SSE channel but retains pubSubInit. If its first user subsequently arrives through setContext() or updateUser(), this guard fails because pubSubInit is still set. The newly created feedback instance then falls through to the existing reinitialization branch and reopens SSE, enabling surveys and connection retries despite the explicit stop. Previously, an anonymous client's identity update returned without opening a connection. Check the idle/stopped state independently of pubSubInit and defer opening the channel until a subsequent initialize().
50b2d4f to
6cce24d
Compare
Problem
A Browser SDK client only set up automatic feedback surveys if it was created with a user. If an app created the client before sign-in and set the user later with
setContext()orupdateUser(), surveys never showed. This affects the React, Vue and React Native SDKs too, since they use the Browser client.Fix
enableAutoFeedback, the prompt handler, position and translations). Offline, server-side and mobile behavior are unchanged.initialize(),initialize()opens the connection as usual.Tests
New cases in
test/feedback-context.test.ts:initialize();enableAutoFeedback: falsestaying off.All three cases fail without the fix. The Browser SDK suite passes, apart from the two release tests that need the React and Node packages built locally.
OpenFeature Browser provider
#847 made the provider stop its client and start a new one when the first user ID arrived, so that feedback would start. With this fix, the provider just updates the existing client's context, so that restart and its bootstrap handling are removed.