Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Start a server with a fresh base dir:
t3 serve --base-dir /tmp/t3-repro --port 37991. - Add a project and run
t3 thread list --project <path> --base-dir /tmp/t3-reprofive times. - Count rows:
SELECT count(*), sum(revoked_at IS NULL) FROM auth_sessions.
Expected behavior
Repeated CLI calls reuse one session, and revoked or expired sessions are removed after a while.
Actual behavior
Each call adds one row. withThreadTools in apps/server/src/cli/thread.ts calls issueMcpClientSession (30-day TTL) for every command and revokes the session when the command ends. The revoked row stays. Nothing in the server deletes rows from auth_sessions, so the table only grows. Five calls added five rows in the repro above.
A CLI process that is killed before its release runs leaves the session active for 30 days.
On a Linux host where agents call t3 thread all day, auth_sessions reached about 44,000 rows in a 12.4 GB database: 42,380 had the label t3 thread cli, and 2,171 of those were still active. New rows arrived at about 440 per hour.
Server traces from that host show SessionStore.verify at p50 4.4 ms, p95 988 ms and max 7.3 s over 600 calls. The lookup itself is a primary-key read. Almost all of that time is waiting for the reader connection (db.lock_wait_ms 7315 of 7320 ms), so the table size is not the direct cause. Each call still adds two writes (insert, then revoke) from a separate CLI process to a busy database.
Impact
Minor bug or occasional failure
Version or commit
Reproduced on nightly 0.1.3-nightly.20261027.3754. The same code path is on main at 08a463e (2026-10-29): issueMcpClientSession plus revokeSession per call in cli/thread.ts, and no DELETE FROM auth_sessions anywhere in apps/server/src.
Environment
Linux server (Node 24) with many CLI callers. macOS desktop build of the same nightly not checked for row counts.
Logs or stack traces
Screenshots, recordings, or supporting files
No response
Workaround
None in stock T3. In our fork we tried two changes, and they held up on a sandbox server:
- The CLI caches its session in a 0600 file under the secrets dir and reuses it until five minutes before expiry. It mints again on a 401 and revokes any session it does not end up caching. 30 calls added 0 rows after the first. 8 parallel calls with no cache left at most 2 active sessions.
- The server deletes revoked rows and expired rows more than a day old. It runs hourly in 500-row batches over
idx_auth_sessions_activeand skips sessions that are still connected. 1,202 stale rows went in three batches of 10, 2.3 and 1.2 ms. Active rows were kept.
Happy to open a PR with focused tests if this direction is acceptable.
Not checked: Windows, and T3 Connect or mobile sessions under the prune on a real device. The prune only removes rows that are revoked or expired, which those clients already treat as signed out.
Activity
mallocator commentedon Nov 28, 2026
Same on 0.1.13 (macOS), at scale: a tool that runs
t3 thread list --jsonabout 14 times a minute has left 644,674 rows inauth_sessionsafter a month. 644,198 of them are revoked, and the oldest expired on 2026-11-11. The table and its indexes take about 230 MB ofstatev2.sqlite(dbstat: table 170 MB,idx_auth_sessions_active59 MB, primary key 31 MB). The table grows by 20k to 110k rows a day.Deleting revoked rows, and rows past
expires_at(at startup or on a timer), would cap it. So would not storing the CLI's short-lived sessions at all.