Skip to content

A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.

Shell

fix(database): change the pool URL port without corrupting credentials

Rudy Celekli0b92c54db42c
diff --git a/engineering/engineering-database-optimizer.md b/engineering/engineering-database-optimizer.md
index fa4f3e18..d1c01985 100644
--- a/engineering/engineering-database-optimizer.md
+++ b/engineering/engineering-database-optimizer.md
@@ -160,11 +160,16 @@ const supabase = createClient(
}
);
-// Use transaction pooler for serverless
-const pooledUrl = process.env.DATABASE_URL?.replace(
- '5432',
- '6543' // Transaction mode port
-);
+// Use the provider's transaction-pooler connection string for serverless.
+// Only when the provider uses the SAME host/credentials and port 6543:
+// change the URL port, never a matching substring in credentials or DB names.
+function transactionPoolUrl(connectionString?: string): string | undefined {
+ if (!connectionString) return undefined;
+ const url = new URL(connectionString);
+ url.port = '6543';
+ return url.toString();
+}
+const pooledUrl = transactionPoolUrl(process.env.DATABASE_URL);
```
## Critical Rules