Harden database state failover diagnostics

This commit is contained in:
Theodore Song
2026-08-19 08:28:24 -04:00
parent 78b832f926
commit 45421c985a
6 changed files with 22 additions and 16 deletions
+2 -3
View File
@@ -19,9 +19,8 @@ export function normalizeDatabaseUrl(raw) {
export function databaseUrls() {
const candidates = [process.env.DATABASE_URL, process.env.NEON_DATABASE_URL]
.map(normalizeDatabaseUrl).filter(Boolean);
const ordered = [...candidates.filter(value => /^postgres(?:ql)?:\/\//i.test(value)),
...candidates.filter(value => !/^postgres(?:ql)?:\/\//i.test(value))];
return [...new Set(ordered)];
const valid = candidates.filter(value => /^postgres(?:ql)?:\/\//i.test(value));
return [...new Set(valid.length ? valid : candidates)];
}
export function databaseUrl() {