Skip to content

Fix websocket auth race for newly created test users#344

Merged
crthpl merged 2 commits intomainfrom
codex/fix-initial-portfolio-race
Feb 18, 2026
Merged

Fix websocket auth race for newly created test users#344
crthpl merged 2 commits intomainfrom
codex/fix-initial-portfolio-race

Conversation

@crthpl
Copy link
Copy Markdown
Contributor

@crthpl crthpl commented Feb 18, 2026

Summary

  • fix a race in ensure_user_created where account creation used non-transactional pool reads/writes
  • perform existence checks + insert + id lookup in one explicit transaction and commit before auth flow continues
  • avoid the transient state where websocket init sends ActingAs before the user portfolio is visible

Root cause

Authentication could create a new account and then immediately continue initialization on a different connection. Without an explicit transaction boundary around creation + lookup, the follow-up portfolio read path sometimes observed the account as missing, causing Account not found logs and occasional client-side KeyError during initialization.

Validation

  • raw websocket auth stress test: 500 sequential new-user connections with no missing-portfolio failures
  • previously flaky scenarios tests repeated 12 times: all passes
  • full scenarios suite (uv run pytest): 26 passed

@crthpl crthpl requested a review from a team as a code owner February 18, 2026 01:43
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
platform Ready Ready Preview, Comment Feb 18, 2026 1:59am

Request Review

@crthpl crthpl merged commit f2c6b1a into main Feb 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant