Nt 3336 optimized entry web hangs in loading state when experience api is blocked or errors#315
Open
Lotfi Anwar L Arif (Lotfi-Arif) wants to merge 6 commits into
Conversation
… API outcomes Introduces a writable `experienceRequestState` signal in `core-sdk` that transitions through `idle -> pending -> success | failed` as the Experience API request progresses. `ExperienceQueue.upsertProfile` writes the signal on each request; success is published in the same reactive batch as the output signals so consumers never observe stale data. Failure is classified as `timeout` (AbortError) or `api-error` (all other throws). Exposes the signal read-only on `CoreStateful.states.experienceRequestState` and exports `ExperienceRequestState` and `ExperienceRequestFailureReason` from the package public API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ails Subscribes useOptimizedEntry to experienceRequestState and sets experienceRequestFailed when the status is 'failed'. Adds that flag as a third escape hatch in the isContentReady expression alongside canOptimize and !optimizationPossible, so OptimizedEntry renders baseline content immediately on API errors, timeouts, or network blocks rather than staying in the loading state indefinitely. Updates sdkTestUtils createRuntime to expose a controllable experienceRequestState observable and setExperienceRequestState helper, and adds the signal to createOptimizationSdk's default states so all test paths have it available. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Documents the experienceRequestState signal — the state machine, transition rules, what failure cases it covers (adblocker, timeout, 4xx/5xx), what it does not cover (no page() call ever made), the consumer pattern used in useOptimizedEntry, and the cross-platform contract all SDK implementations must honour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
internal concept doc
Charles Hudson (phobetron)
previously approved these changes
Jun 10, 2026
Charles Hudson (phobetron)
left a comment
Collaborator
There was a problem hiding this comment.
I think we're good now 😃
…ntry and tests This update introduces the `experienceRequestState` signal into the `OptimizedEntry` component and its associated tests. The state transitions are now handled to reflect loading, success, and failure scenarios, ensuring that the component behaves correctly based on the API request outcomes. Additionally, the tests have been updated to utilize the new `setExperienceRequestState` helper for better control over the experience request lifecycle.
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.
Previously, OptimizedEntry could remain in a loading state forever when an Experience API request never produced a usable result. If the request failed, timed out, or was blocked by something like an ad blocker, visitors could be left looking at a blank section instead of baseline content.
This change makes loading depend on one explicit signal: whether an Experience request is currently in flight. It uses the experienceRequestState signal from core-sdk (idle -> pending -> success | failed) and updates useOptimizedEntry to exit loading whenever the request is no longer pending.
That means:
This closes the infinite-loading behavior for failed requests, blocked requests, consent-gated setups, and cases where no optimization-triggering event is ever sent. It also simplifies the rendering contract: loading now means only “an Experience API request is in progress,” not “optimization might still happen later.”
Additionally, reset() now restores experienceRequestState to idle, and the Experience queue updates selectedOptimizations and request success atomically so React consumers do not observe an inconsistent intermediate state.