Commit Graph
2814 Commits
Author SHA1 Message Date
Bilal Godil 91e7266a21 Fix flaky ClickHouse sync tests: wait for CH in CI + add debug logging
- Add "Wait on ClickHouse" step (tcp:8136) before db:init in CI
- Log last response status/body in timeout errors for debugging
- Move ClickHouse tests to run first in sequential block
- Narrow dev-test workflows to only run db sync tests
2026-02-12 16:39:12 -08:00
Bilal Godil 3cde6faaa8 fix test ordering 2026-02-12 16:30:39 -08:00
Bilal Godil 3db832e610 Increase ClickHouse poll interval from 500ms to 2s 2026-02-12 15:56:04 -08:00
Bilal Godil 0dc2e94a23 fix clickhouse needsResync 2026-02-12 15:24:23 -08:00
Bilal Godil 558d0f667d Merge branch 'external-db-sync-clickhouse-default' of https://github.com/stack-auth/stack-auth into external-db-sync-clickhouse-default 2026-02-12 14:02:29 -08:00
Bilal Godil 62d054e568 fix tests 2026-02-12 14:02:15 -08:00
BilalG1andGitHub 02b6ef6088 Merge branch 'dev' into external-db-sync-clickhouse-default 2026-02-12 13:21:26 -08:00
Konstantin Wohlwend 621ada20a0 Better error message for expired access tokens
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Mirror main branch to main-mirror-for-wdb / lint_and_build (push) Has been cancelled
Publish npm packages / publish (push) Has been cancelled
Dev Environment Test With Custom Base Port / restart-dev-and-test-with-custom-base-port (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests with custom base port / setup-tests-with-custom-base-port (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
Publish Swift SDK to prerelease repo / publish (push) Has been cancelled
Sync Main to Dev / sync-commits (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
2026-02-12 12:29:11 -08:00
Bilal Godil a509be3f61 fix type issue 2026-02-12 11:28:59 -08:00
BilalG1andGitHub afa76be8cf token refresh event change (#1162)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->
2026-02-12 11:02:33 -08:00
BilalG1andGitHub 90eb9ae523 Merge branch 'dev' into external-db-sync-clickhouse-default 2026-02-12 11:01:35 -08:00
Konstantin Wohlwend f656ee7a0e Increase email retry count to 9 2026-02-11 20:51:34 -08:00
Konstantin Wohlwend 23b2078d9e Increase email retries further 2026-02-11 20:42:51 -08:00
Bilal Godil 1421461bc3 Add TEST_TIMEOUT to ClickHouse sync tests 2026-02-11 20:32:40 -08:00
Bilal Godil 4ab4be8d56 merge dev 2026-02-11 19:43:19 -08:00
Bilal Godil cf5558ee5d pr comment fixes 2026-02-11 19:42:05 -08:00
Konstantin Wohlwend 6107c67335 chore: update package versions 2026-02-11 19:19:06 -08:00
Konstantin Wohlwend 95d383951a More email retries 2026-02-11 19:12:05 -08:00
aadesh18andGitHub 92087c8a5c Refactor admin/client interfaces (edited projectOwnerSession) (#1190) 2026-02-11 19:06:57 -08:00
Konstantin Wohlwend ee9912fafb Decrease Nodemailer limits 2026-02-11 18:55:58 -08:00
Konstantin Wohlwend e621510c62 Update AGENTS.md 2026-02-11 13:14:00 -08:00
Konstantin Wohlwend f493b27c7b Trust own domain 2026-02-11 13:12:38 -08:00
Konstantin Wohlwend b0559bce55 Increase transaction retry count 2026-02-11 11:47:10 -08:00
Konstantin Wohlwend fecc5a4a3f chore: update package versions 2026-02-11 11:34:34 -08:00
Konstantin Wohlwend 5494aac42a Increase max duratoin limit 2026-02-11 10:58:25 -08:00
Konstantin Wohlwend e5a354617c Fix restricted user schema 2026-02-11 10:52:55 -08:00
Konstantin Wohlwend 2288c9c65c Port 2465 should have implicit TLS from byte 1 2026-02-11 10:08:59 -08:00
Madison 02c67ef532 fix docs overview date 2026-02-11 10:36:24 -06:00
MadisonandGitHub 2b4e208713 [Docs] Update docs to openrouter usage for ai chat (#1112)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
  * Switched AI provider for improved streaming and model selection.
* Updated chat UI: smoother near-bottom scrolling, refined layout, and
visual enhancements.

* **Documentation**
  * Removed legacy Stack Auth setup guide from docs.

* **Chores**
* Updated docs dependencies and environment configuration; added new API
key variable and removed an old global key.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-11 10:16:43 -06:00
Konsti WohlwendandGitHub adb14f1635 [Refactor] Improve CI Run Times by Reducing Test Flakiness and Speeding up Test Suite (#1166) 2026-02-10 19:43:10 -08:00
Konstantin Wohlwend 7bda141ca5 Show request duration warning after 240s for long requests 2026-02-10 18:31:56 -08:00
Konstantin Wohlwend 419a9c4367 Better logging for unknown email errors 2026-02-10 18:16:30 -08:00
Konstantin Wohlwend 2f7acb4ff5 Add STACK_OPENAI_API_KEY to .env.development 2026-02-10 09:42:35 -08:00
BilalG1andGitHub 8534caaf27 Merge branch 'dev' into external-db-sync-clickhouse-default
DB migrations are backwards-compatible / Check if migrations changed (push) Has been cancelled
DB migrations are backwards-compatible / Test migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migrations are backwards-compatible / No migration changes (skipped) (push) Has been cancelled
2026-02-09 12:07:29 -08:00
Konstantin Wohlwend d914d7f3ec Split DB migration into two files
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
DB migrations are backwards-compatible / Check if migrations changed (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test With Custom Base Port / restart-dev-and-test-with-custom-base-port (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests with custom base port / setup-tests-with-custom-base-port (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
Mirror main branch to main-mirror-for-wdb / lint_and_build (push) Has been cancelled
Publish npm packages / publish (push) Has been cancelled
Sync Main to Dev / sync-commits (push) Has been cancelled
DB migrations are backwards-compatible / Test migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migrations are backwards-compatible / No migration changes (skipped) (push) Has been cancelled
2026-02-09 11:25:50 -08:00
Konstantin Wohlwend f2f44086d8 Merge existing DB sync migrations 2026-02-09 11:20:17 -08:00
BilalG1andGitHub 2072dd4b3d force db sync button (#1167) 2026-02-09 10:53:55 -08:00
Konstantin Wohlwend b182c1b03d Metadata on teams detail page
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
DB migrations are backwards-compatible / Check if migrations changed (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test With Custom Base Port / restart-dev-and-test-with-custom-base-port (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests with custom base port / setup-tests-with-custom-base-port (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
DB migrations are backwards-compatible / Test migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migrations are backwards-compatible / No migration changes (skipped) (push) Has been cancelled
2026-02-06 18:33:31 -08:00
BilalG1andGitHub fcf493e65c Merge branch 'dev' into external-db-sync-clickhouse-default 2026-02-06 11:31:31 -08:00
Aman GanapathyandGitHub 7c7e97d11e [Chore] Bump timeout for email monitor (#1163)
### Context
A small amount of email monitor requests take slightly less than 3
minutes to complete. This meant our old timeout of 2 minutes was
flagging a few kuma pulls as "down" when they weren't.

### Summary of Changes
We just bumped the timeout. This should be ok in prod because the uptime
kuma timeout is set to 200 seconds.
2026-02-06 09:25:53 -08:00
Bilal Godil b673ab5ac6 fix lint 2026-02-05 14:19:50 -08:00
Bilal Godil b83063c224 move test 2026-02-05 14:00:48 -08:00
Bilal Godil 925a8654e4 fix zod version 2026-02-05 13:24:53 -08:00
Bilal Godil 45e7d2dd1e merge dev 2026-02-05 12:13:47 -08:00
BilalG1andGitHub 9c340f466d Merge branch 'external-db-sync' into external-db-sync-clickhouse-default 2026-02-05 12:05:29 -08:00
2055d98dea External db sync (#1036)
<img width="1920" height="969" alt="Screenshot 2026-02-04 at 9 47 16 AM"
src="https://github.com/user-attachments/assets/d7d0cd04-0051-4fc4-b857-e6f87ee97a59"
/>

**This PR revolves around the following components**
1. Sequencer - sequences the updates in the internal db
2. Poller - polls for the latest updates to sync with the external db
3. Outgoing Request Handler - essentially a trigger that can make http
requests based on a change in the internal db
4. Sync Engine - syncs with the latest changes from the internal db to
the external db

**What has been done**
- Added a global sequence id for ProjectUser, ContactChannel and
DeletedRow.
- Added the deletedRow table to keep track of the rows that were deleted
across ProjectUser and ContactChannel.
- Added the OutgoingRequest table to keep track of the outgoing requests
- Added function for the sequencer to call to sequence updates
- Added a sequencer that sequences all the changes in the internal db
every 50 ms
- Added a poller that polls for the latest changes in the internal db
every 50 ms, and adds to a queue
- Added a Vercel cron that calls sequencer and poller every minute
- Added a queue that fulfills the outgoing requests by making http calls
(for external db sync, it calls the sync engine endpoint)
- Added a sync engine that uses the defined sql mapping query in the
user's schema to pull in the changes for the user, and sync them with
the external db
- Added tests to test out each functionality


**How to review this PR:**
1. Review the migrations (sequence id, deletedRow, triggers, backlog
sync) (all files created under the migrations folder)
2. Review sequencer
3. Review poller
4. Review the changes in schema
5. Review sync-engine (the function, and it's helper file)
6. Review the schema changes, and query mappings
7. Review the tests (basic, advanced and race, along with the helper
file)
8. Review the changes made in Dockerfile to support local testing using
the postgres docker

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Introduces a cron-driven external DB sync pipeline with global
sequencing, internal poller and webhook sync engine, new DB
tables/functions, config schema/mappings, and comprehensive e2e tests.
> 
> - **Database (Prisma/Migrations)**:
> - Add global sequence (`global_seq_id`) and
`sequenceId`/`shouldUpdateSequenceId` to `ProjectUser`,
`ContactChannel`, `DeletedRow` with partial indexes.
> - Create `DeletedRow` (capture deletes) and `OutgoingRequest` (queue)
tables; add unique/indexes.
> - Add triggers/functions: `log_deleted_row`,
`reset_sequence_id_on_update`, `backfill_null_sequence_ids`,
`enqueue_tenant_sync`.
> - **Backend/API**:
> - New internal routes: `GET
/api/latest/internal/external-db-sync/sequencer`, `GET /poller`, `POST
/sync-engine` (Upstash-verified) for sync orchestration.
> - Add cron wiring: `vercel.json` schedules and local
`scripts/run-cron-jobs.ts`; start in dev via `dev` script.
> - Tweak route handler (remove noisy logging) without behavior change.
> - **Sync Engine**:
> - Implement `src/lib/external-db-sync.ts` to read tenant mappings and
upsert to external Postgres (schema bootstrap, param checks,
sequencing).
> - Add default mappings `DEFAULT_DB_SYNC_MAPPINGS` and config schema
`dbSync.externalDatabases` in shared config.
> - **Testing/Infra**:
> - Add extensive e2e tests (basics, advanced, race conditions) for
sequencing, idempotency, deletes, pagination, multi-mapping, and
permissions.
> - Docker compose: add `external-db-test` Postgres for tests; e2e deps
for `pg` types.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3f2a8efcfb. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* External PostgreSQL sync: automatic, batched replication with
mappings, resume/idempotency, and on-demand enqueueing.

* **Admin UI**
* Real-time External DB Sync dashboard and status API showing
per-mapping backlog, sequencer/poller/sync-engine telemetry, and fusebox
controls.

* **Tests**
* Large e2e suite: basic, advanced, race, high-volume tests and test
utilities for external DB sync.

* **Chores**
* DB migrations, CI/workflow updates, background cron runner and
local/dev test support.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Konsti Wohlwend <[email protected]>
Co-authored-by: Bilal Godil <[email protected]>
2026-02-05 12:04:31 -08:00
Konstantin Wohlwend cf86ea5952 Proxy caching 2026-02-05 11:30:40 -08:00
Bilal Godil 63df87a71d fix test 2026-02-05 10:00:49 -08:00
Bilal Godil 445e889bbb Merge branch 'external-db-sync' of https://github.com/stack-auth/stack-auth into external-db-sync 2026-02-04 19:40:58 -08:00
Bilal Godil caa3dcaaff remove fusebox sync engine col 2026-02-04 19:40:53 -08:00