Repository navigation
Make fewer database round trips per control-plane request - #294
Merged
Merged
Conversation
Every request reads the session. With an account admission check, a hook read the session and user before the session endpoint read them again. The check now runs on the session the endpoint returns. Reads on page navigation ran in a transaction, and the app lookup locked its row, so each read paid for begin and commit. They now run without a transaction and read the app without a lock. Writes keep both. On Cloudflare each request builds its own auth instance, so Better Auth validated the schema on every request. Node still validates it once.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | fe83a35 | Nov 22 2026, 02:21 PM |
Passing validateSchema: true explicitly turns Better Auth's note about adapters it cannot validate into a warning, which the social sign-in tests rejected. Only the Cloudflare runtime now sets the option.
Admission ran before each session lookup and read the user's admission state on every request. An installation that blocks a user ends their sessions, and new sessions, tokens and account changes are still checked, so session lookups no longer repeat the check.
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.
On a hosted installation, a control-plane query such as
getAppsmade 11 database queries in a row. Traces showed several that only repeated or wrapped other work:beginandcommitaround a single readChanges
Account admission: with an
allowUsercheck, the before hook on/get-sessionread the session and user and the user's admission state, and the endpoint then read the session and user again. Session lookups no longer run the check. An installation that blocks a user ends their sessions; the hosted ban does this through Better Auth's admin plugin. New sessions,/tokenand the account paths still check admission.Reads without a transaction:
readOnlyruns a read with the same error mapping astransact, but withoutbeginandcommit.readableAppreads an app with the same visibility rules asmanagedApp, withoutFOR UPDATE. They replace the transaction and the row lock in the reads that page navigation makes:Writes still use
transactand lock the app row.Schema validation on Cloudflare: Better Auth validates the schema the first time each auth instance is used. The Cloudflare runtime builds an instance per request, so the check ran on every request. It is turned off there. Node builds one instance per process and keeps the check, so tests still run it.
Queries per navigation
Measured locally against
main. The local server has noallowUsercheck, so the three admission reads that hosted installations also save per request do not appear here.maingetApps)getAppDetails)getCatalog)getMembers)Validation
pnpm checkauthentication-extension.integration.test.ts, whose unavailable account still gets 403 from/get-session.

Confidence Score: 5/5
The PR appears safe to merge with the stated requirement that extensions revoke blocked users’ sessions.Summary
Reduces database round trips for control-plane reads.
No new actionable issues were found in the changes since the previous review.
Reviews (3) · Last reviewed commit: "Stop rechecking account admission on eve..." · Reviewed by Greptile