Repository navigation
test: add e2e checks for the evaluation sync status listener - #358
Draft
duyhungtnn wants to merge 9 commits into
Draft
duyhungtnn wants to merge 9 commits into
duyhungtnn wants to merge 9 commits into
Conversation
Apps can now see when updating flag values (polling or streaming) fails and when it works again. - New public API on BKTClient: evaluationSyncStatus(), addEvaluationSyncStatusListener(), removeEvaluationSyncStatusListener(), clearEvaluationSyncStatusListeners(). - New exported types: BKTEvaluationSyncStatus, BKTEvaluationSyncState, BKTEvaluationSyncSource, BKTEvaluationSyncError, BKTEvaluationSyncStatusListener. - States: INITIALIZING, SYNCED, FAILING, DESTROYED. Listeners are called on every state change and on every failure that is not ignored. - Stream failures now give the same BKTException types as polling. StreamConnection reports raw facts, StreamingTask maps them, and statusToBKTException is the one shared HTTP status mapping.
A listener that destroys the client, or removes another listener, no longer causes a removed listener to be called. Before, the other listeners got DESTROYED twice.
A sync status listener that calls initializeBKTClient() on DESTROYED now gets a new client. Before, the old client was still registered, so init returned early and the old client was removed right after.
…lient during init A sync status listener can call destroyBKTClient() while TaskScheduler.start() runs, for example when the stream fails to open. TaskScheduler now starts no more tasks after stop(), and scheduleAndFetch() skips the first fetch when the client was destroyed.
… component destroyBKTClient() now calls a method on the client, like resetTasks() and clearEvaluationUpdateListeners(). No behavior change.
When initializeCache() rejects, the client is removed but its sync status stayed INITIALIZING, so a listener added while init was pending never heard the end. It now gets DESTROYED after clearInstance(), so the listener can start a new client.
There was a problem hiding this comment.
🟡 Changes recommended
The streaming test can pass on the init failure alone without verifying that fallback polling starts or reports its failure.
1 open issue
What changed in this PR
Adds real-backend end-to-end coverage for the evaluation sync status API introduced in #357, supporting #355’s failure and recovery notifications.
Changes:
- Verifies polling initialization reports
SYNCEDto a listener registered before awaiting initialization. - Adds status and error assertions for successful streaming and recovery after an initialization timeout.
- Adds a wrong-API-key scenario covering authentication failures and polling fallback.
| File | Description |
|---|---|
e2e/streaming.spec.ts |
Adds sync-status assertions and an invalid-key fallback test. |
e2e/BKTClient.spec.ts |
Tests polling initialization status, timestamps, and listener notification. |
Review effort: Balanced
duyhungtnn
marked this pull request as ready for review
November 10, 2026 13:22
duyhungtnn
marked this pull request as draft
November 19, 2026 09:05
duyhungtnn
force-pushed
the
feat/status-listener
branch
2 times, most recently
from
November 26, 2026 08:23
e4bc637 to
1973bf1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Part of #355. Builds on #357.
What
E2E checks for the evaluation sync status, against the real backend:
SYNCED.lastSyncedAtis set,lastErroris null.SYNCED, no error.SYNCED.lastErrorkeeps the initTimeoutException(sourcePOLLING).ForbiddenException. The stream gets 401, so the SDK falls back to polling, which gets 403 again. The status endsFAILINGwith the polling error.Notes
get_evaluationsand 401 on the stream. The wrong key test waits for both answers, because they can arrive in either order.