Skip to content

Fix sync server startup against a sleeping database - #2

Merged
lobbystack merged 1 commit into
mainfrom
fix/sync-database-startup
Sep 16, 2026
Merged

lobbystack merged 1 commit into
mainfrom
fix/sync-database-startup

Conversation

@lobbystack

Copy link
Copy Markdown
Owner

The server crashed into a restart loop when its Postgres schema probe ran while the managed database was still waking after scale-to-zero. Railway logs showed repeated connect ETIMEDOUT/connect ECONNREFUSED and uncaught-error restarts.

  • Add bounded startup retry with exponential backoff around store.ready() (60 attempts, 1s doubling to a 5s cap) so the process waits for the database instead of crashing.
  • Set connect_timeout: 10 on the postgres client so each failed TCP attempt fails fast.
  • Patch Better Auth's Postgres type allowlist to recognise the internal int8/int2/float4/float8 type names, silencing a false rateLimit.lastRequest type warning. The column is correctly bigint (epoch milliseconds); no schema change.
  • Add provenance for the patch and regression tests for both changes.

Tests: startup retry unit tests, dependency-patch guard, existing server suite.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@lobbystack
lobbystack merged commit 01b2282 into main Sep 16, 2026
0 of 12 checks passed
@lobbystack
lobbystack deleted the fix/sync-database-startup branch September 16, 2026 17:28
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