-
Notifications
You must be signed in to change notification settings - Fork 0
docs: KB-002 — Hyperdrive postgres:// scheme rejected by Zod, database: down with latency_ms: 0
#1407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: KB-002 — Hyperdrive postgres:// scheme rejected by Zod, database: down with latency_ms: 0
#1407
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,205 @@ | ||||||||||||
| # KB-002: Hyperdrive Binding Connected but `database` Service Reports `down` | ||||||||||||
|
|
||||||||||||
| > **Status:** ✅ Active | ||||||||||||
| > **Affected version:** v0.75.0 | ||||||||||||
| > **Resolved in:** PR fixing `PrismaClientConfigSchema` to accept `postgres://` + enhanced `/api/health` probe | ||||||||||||
| > **Date:** 2026-03-25 | ||||||||||||
|
|
||||||||||||
| --- | ||||||||||||
|
|
||||||||||||
| ## Symptom | ||||||||||||
|
|
||||||||||||
| The live site at `https://adblock-frontend.jayson-knight.workers.dev/` displays two error banners: | ||||||||||||
|
|
||||||||||||
| - **"Degraded performance — v0.75.0"** | ||||||||||||
| - **"Data may be stale"** | ||||||||||||
|
|
||||||||||||
| Hitting the health endpoint returns: | ||||||||||||
|
|
||||||||||||
| ```json | ||||||||||||
| { | ||||||||||||
| "status": "down", | ||||||||||||
| "version": "0.75.0", | ||||||||||||
| "timestamp": "2026-03-25T21:59:15.917Z", | ||||||||||||
| "services": { | ||||||||||||
| "gateway": { "status": "healthy" }, | ||||||||||||
| "database": { "status": "down", "latency_ms": 0 }, | ||||||||||||
| "compiler": { "status": "healthy" }, | ||||||||||||
| "auth": { "status": "healthy", "provider": "better-auth" }, | ||||||||||||
| "cache": { "status": "healthy", "latency_ms": 132 } | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| **Key tell:** `latency_ms: 0` on the `database` service. | ||||||||||||
| A real network failure or timeout always returns a non-zero latency. An instant `0 ms` failure means the probe threw *before* any connection attempt — i.e., at the validation layer. | ||||||||||||
|
Comment on lines
+34
to
+35
|
||||||||||||
| **Key tell:** `latency_ms: 0` on the `database` service. | |
| A real network failure or timeout always returns a non-zero latency. An instant `0 ms` failure means the probe threw *before* any connection attempt — i.e., at the validation layer. | |
| **Key tell:** `latency_ms: 0` (or near-zero) on the `database` service. | |
| Real network failures or timeouts typically show a non-zero latency. A `0 ms` (or near-zero) failure is a strong hint that the probe threw *before* any connection attempt — for example, at the validation/parse layer — but you should confirm this by checking logs for a `ZodError` as described below. |
Copilot
AI
Mar 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “After the fix” snippet uses .regex(/^postgre(?:s|sql):\/\//) but the current PrismaClientConfigSchema implementation in worker/lib/prisma-config.ts uses .refine((s) => s.startsWith('postgresql://') || s.startsWith('postgres://'), ...). To avoid drift/confusion, update the snippet (or clearly label it as pseudo-code) to match the repo’s actual implementation and error message.
| // After the fix — accepts both schemes | |
| connectionString: z.string().url().regex(/^postgre(?:s|sql):\/\//), | |
| // After the fix — accepts both schemes (postgres:// and postgresql://) | |
| connectionString: z.string().url().refine((s) => s.startsWith('postgresql://') || s.startsWith('postgres://')), |
Copilot
AI
Mar 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section repeats the “Before/After” code snippet for PrismaClientConfigSchema, but the “After” example uses .regex(/^postgre(?:s|sql):\/\//) which doesn’t match the current implementation (it uses .refine(...) with startsWith('postgres://') || startsWith('postgresql://')). Please align the snippet here as well so the Resolution steps are accurate for operators following the KB.
| connectionString: z.string().url().regex(/^postgre(?:s|sql):\/\//), | |
| connectionString: z.string().url().refine( | |
| (value) => value.startsWith('postgres://') || value.startsWith('postgresql://'), | |
| { message: 'connectionString must start with "postgres://" or "postgresql://"' }, | |
| ), |
Copilot
AI
Mar 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example enhanced health response shows db_name: "neondb", but the worker’s health probe currently treats db_name !== 'adblock-compiler' as a degraded/wrong-database condition. Using neondb in the “healthy” example can mislead responders. Suggest updating the example to the expected production DB name for this repo (or making the example explicitly generic).
| "db_name": "neondb", | |
| "db_name": "adblock-compiler", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR description says KB-002 should “follow the exact same structure as KB-001”. KB-001 starts with a consistent metadata block (Series/Component/Service URL/Date Created/Status), but KB-002 uses a different header format and omits several of those fields. If consistent KB structure is a goal, consider matching KB-001’s header metadata format here (or update the PR description if the divergence is intentional).