The problem
The generated rawOpensaasContext is a one-shot promise. If the process boots before its database accepts connections, the promise rejects once and stays rejected for the life of the process, and everything built on it — notably createAuth, which wraps it in a lazy Proxy — rejects on every subsequent request.
Found on PR #1375 (issue #1170): the Playwright harness started Next before the sidecar was reachable and every /api/auth/* route failed until restart. The harness now serves under opensaas dev, which sequences the database first, so the e2e suite no longer hits it. A production cold start racing a database blip would.
What to do
Decide the contract and make it true:
- Either the promise retries construction on failure (a rejected first attempt does not poison later ones — memoise only success), or
- The generated context refuses to be created before the database is reachable and says so, and the guidance tells deployers to sequence accordingly.
Whichever is chosen: a test that rejects the first connection attempt and confirms the second succeeds (or confirms the documented refusal), and packages/core/CLAUDE.md / the deploy guide stating the behaviour.
Context
🤖 Generated with Claude Code
The problem
The generated
rawOpensaasContextis a one-shot promise. If the process boots before its database accepts connections, the promise rejects once and stays rejected for the life of the process, and everything built on it — notablycreateAuth, which wraps it in a lazy Proxy — rejects on every subsequent request.Found on PR #1375 (issue #1170): the Playwright harness started Next before the sidecar was reachable and every
/api/auth/*route failed until restart. The harness now serves underopensaas dev, which sequences the database first, so the e2e suite no longer hits it. A production cold start racing a database blip would.What to do
Decide the contract and make it true:
Whichever is chosen: a test that rejects the first connection attempt and confirms the second succeeds (or confirms the documented refusal), and
packages/core/CLAUDE.md/ the deploy guide stating the behaviour.Context
🤖 Generated with Claude Code