Repository navigation
Fix first-load session race (live: 10/20 loads failed) - #2
Merged
Merged
Conversation
…rst load across two sessions
On the live deployment the boot requests and the initial scenario load each started a session concurrently;
when the older session's response landed last, the page read a session that did not own the proposal
('proposal not found in this session', 10 of 20 fresh loads). Engine, API and policies unchanged.
Adds a deterministic Playwright regression test (holds the first session response until the scenario exists).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideFixes the first-load session race by serializing UI session creation, ensuring a late response cannot replace the session that owns the newly created scenario. Adds a deterministic Playwright regression test and updates the documented E2E count; server-side behavior is unchanged. Sequence diagram for serialized first-load session creationsequenceDiagram
participant UI as UI client
participant API as Session API
participant Scenario as Scenario API
participant Browser as Browser cookie jar
UI->>UI: newSession()
UI->>API: POST /api/session A
UI->>UI: newSession() waits for sessionPromise
API-->>Browser: Set-Cookie session A
UI->>API: POST /api/session B
API-->>Browser: Set-Cookie session B
UI->>Scenario: POST /api/scenarios/*
Scenario-->>UI: scenario owned by session B
UI->>Scenario: GET /api/scenarios/*
Scenario-->>UI: scenario found in session B
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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.
Problem
On the public deployment of v1.0.0 (https://decide-demo.onrender.com), 10 of 20 fresh page loads showed
Error: proposal not found in this session.At boot,
GET /api/scenarioslazily creates session A whileload()explicitly creates session B. Both POSTs run concurrently. If A'sSet-Cookielands after the scenario was created under B, every later request carries A. Localhost latency hid the race.Fix
ui/src/api.ts:newSession()chains after any in-flight session creation, so the last cookie stored is always the session the caller awaited. The UI client is the only code change. The engine, API, policies and evaluator are unchanged.Test
New Playwright test that holds the first session response until the scenario exists. It fails on v1.0.0 and passes with the fix. Results: 10/10 E2E, 95/95 unit tests, typecheck clean.
Not deployed. Deploying requires the owner's approval, because the live service is pinned to v1.0.0 (
7e77900).🤖 Generated with Claude Code
Summary by Sourcery
Serialize concurrent session creation to ensure initial page loads consistently use the session associated with their scenario.
Bug Fixes:
Documentation:
Tests: