Skip to content

Commit

Permalink
Increase connections
Browse files Browse the repository at this point in the history
  • Loading branch information
omfj committed Jan 28, 2025
1 parent 6e9388c commit c8b6cef
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions packages/db/src/serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import type postgres from "postgres";

import { createDatabase, createPool } from "./create";

const MAX_POOL = 1;
const IDLE_TIMEOUT = 10000; // 10 seconds
const CONNECT_TIMEOUT = 1000; // 1 seconds

const globalForPool = globalThis as unknown as {
pool: ReturnType<typeof postgres> | undefined;
};
Expand All @@ -14,19 +10,11 @@ let pool;

if (process.env.NODE_ENV !== "production") {
if (!globalForPool.pool) {
globalForPool.pool = createPool({
max: MAX_POOL,
idle_timeout: IDLE_TIMEOUT,
connect_timeout: CONNECT_TIMEOUT,
});
globalForPool.pool = createPool();
}
pool = globalForPool.pool;
} else {
pool = createPool({
max: MAX_POOL,
idle_timeout: IDLE_TIMEOUT,
connect_timeout: CONNECT_TIMEOUT,
});
pool = createPool();
}

export const db = createDatabase(pool);

0 comments on commit c8b6cef

Please sign in to comment.