History

mac connections

Rhys Sullivan committed 8 months ago

Commit 67c45121 parent 29e4b722 files · +20 −1Browse files

Unified · Split

2 files
  1. apps/web/app/api/control-plane/[...path]/route.ts +5 −0
  2. packages/persistence-sql/src/sql-internals.ts +15 −1
apps/web/app/api/control-plane/[...path]/route.ts+5−0
@@ -105,6 +105,11 @@ const handle = async (request: NextRequest, context: RouteContext): Promise<Resp · 104 unmodified lines
105105
106106 return runtime.handleControlPlane(applyPrincipalHeaders(controlPlaneRequest, principal));
107107 } catch (cause) {
108+ console.error("[control-plane] request failed", {
109+ method: request.method,
110+ path: request.nextUrl.pathname,
111+ cause,
112+ });
108113 return storageErrorResponse("control-plane.request", cause);
109114 }
110115 };
packages/persistence-sql/src/sql-internals.ts+15−1
@@ -67,6 +67,20 @@ type SqlRuntime = { · 66 unmodified lines
6767 close: () => Promise<void>;
6868 };
6969
70+const resolvePostgresMaxConnections = (): number => {
71+ const configured = process.env.CONTROL_PLANE_POSTGRES_MAX_CONNECTIONS
72+ ?? process.env.POSTGRES_MAX_CONNECTIONS;
73+
74+ if (configured) {
75+ const parsed = Number.parseInt(configured, 10);
76+ if (Number.isFinite(parsed) && parsed > 0) {
77+ return parsed;
78+ }
79+ }
80+
81+ return process.env.NODE_ENV === "production" ? 1 : 10;
82+};
83+
7084 const sanitizePostgresUrl = (value: string): string => {
7185 try {
7286 const parsed = new URL(value);
@@ -108,7 +122,7 @@ const createPostgresRuntime = async ( · 35 unmodified lines
108122 ): Promise<SqlRuntime> => {
109123 const client = postgres(sanitizePostgresUrl(databaseUrl), {
110124 prepare: false,
111− max: 10,
125+ max: resolvePostgresMaxConnections(),
112126 ...(applicationName ? { connection: { application_name: applicationName } } : {}),
113127 });
114128

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t