Skip to content

Fix user uid handling and WS handshake in backend#121

Merged
bitbacchus merged 2 commits into
ecomod-code:fix-auth-race-conditionfrom
bitbacchus:claude/fix-auth-race-condition-oJOKj
May 20, 2026
Merged

Fix user uid handling and WS handshake in backend#121
bitbacchus merged 2 commits into
ecomod-code:fix-auth-race-conditionfrom
bitbacchus:claude/fix-auth-race-condition-oJOKj

Conversation

@bitbacchus
Copy link
Copy Markdown
Member

needs more testing

claude added 2 commits May 20, 2026 12:57
…king

FingerprintStore.Block and Unblock retrieve the user record via
GetByFingerprint to find the user's uid, but then sent
UserStoreMessages.Update with `uid: fp.uid`, which is the fingerprint
id — so the wrong record (or no record) was being updated. Pass the
user's uid instead.
The WS authentication middleware previously did

  system.send(SessionStore, StoreSession({ uid, actorSystem }));
  next(undefined);

— a fire-and-forget that returned the HTTP 101 to the client before the
SessionStore's clientIndex had been updated with the new actorSystem ↔
uid mapping. The browser would then immediately ask actors that resolve
the caller's role via determineRole → SessionStore.GetSessionForClient,
which would miss in clientIndex and return "Unknown client session".

This produced a ~30 second Dashboard reload spinner: the frontend's
afterStart asks (UserAdminActor.GetAll, FingerprintStore.GetMostRecent,
LocalUserActor.GetOwn) would hit timeouts (5s each + 5s sweep) before
the system Promise could resolve and the spinner could clear.

Converting send → ask makes the handshake wait until clientIndex is
populated, so the very first ask the new client sends resolves its
session correctly.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/backend/src/actors/FingerprintStore.ts 0.00% 2 Missing ⚠️
packages/backend/src/middlewares/authMiddleware.ts 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@bitbacchus bitbacchus merged commit d9651d3 into ecomod-code:fix-auth-race-condition May 20, 2026
1 of 2 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.

2 participants