@protobase/server 0.66.4 → 0.66.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,9 +34,11 @@ export type PgModule<P extends PgPool> = {
34
34
  * runtime's, which `protobase dev` and `serve` open, and the one the app's own code uses, such as its Better Auth store.
35
35
  * Whoever asks first opens it, and everyone in the process shares it, across a dev server's reloads too, until it ends;
36
36
  * so the app never opens more connections than it may. Date and timestamp (without zone) come back as text, which the
37
- * API formats itself, a dropped connection is printed rather than fatal, and a query waits at most `poolWaitMs` for a
38
- * free connection. Idle connections keep no process alive, so a command exits when its work is done even while
39
- * nobody ends the pool, such as one that sent no query of its own after Better Auth's schema check.
37
+ * API formats itself, a dropped connection is printed rather than fatal, and a new connection may take `connectTimeoutMs`
38
+ * to open, as long as a database takes to wake. A query that finds every connection in use waits at most `poolWaitMs`
39
+ * for one where the runtime connects (`connectOrBusy`), and `connectTimeoutMs` elsewhere. Idle connections keep no
40
+ * process alive, so a command exits when its work is done even while nobody ends the pool, such as one that sent no
41
+ * query of its own after Better Auth's schema check.
40
42
  */
41
43
  export declare const appPool: <P extends PgPool>(pg: PgModule<P>, url: string, max?: number) => P;
42
44
  /**
package/dist/app-pool.js CHANGED
@@ -3,6 +3,11 @@ import { handleDroppedConnections } from "./dropped-connections.js";
3
3
  //#region src/app-pool.ts
4
4
  /** How long a query waits for a free connection of the app's pool before it fails with `ConnectionsBusy`. */
5
5
  const poolWaitMs = 2e3;
6
+ /**
7
+ * How long the app's pool waits for a new connection to open: long enough for a database that scaled to zero to wake,
8
+ * which the platform's pooler holds the login for, and under that pooler's own login timeout (60 s by default).
9
+ */
10
+ const connectTimeoutMs = 3e4;
6
11
  /** How many connections the app's pool opens: `PROTOBASE_DB_CONNECTIONS`, such as its plan's limit, or 10. */
7
12
  const readDbConnections = (env) => {
8
13
  if (!env.PROTOBASE_DB_CONNECTIONS) return 10;
@@ -17,9 +22,11 @@ const store = globalThis;
17
22
  * runtime's, which `protobase dev` and `serve` open, and the one the app's own code uses, such as its Better Auth store.
18
23
  * Whoever asks first opens it, and everyone in the process shares it, across a dev server's reloads too, until it ends;
19
24
  * so the app never opens more connections than it may. Date and timestamp (without zone) come back as text, which the
20
- * API formats itself, a dropped connection is printed rather than fatal, and a query waits at most `poolWaitMs` for a
21
- * free connection. Idle connections keep no process alive, so a command exits when its work is done even while
22
- * nobody ends the pool, such as one that sent no query of its own after Better Auth's schema check.
25
+ * API formats itself, a dropped connection is printed rather than fatal, and a new connection may take `connectTimeoutMs`
26
+ * to open, as long as a database takes to wake. A query that finds every connection in use waits at most `poolWaitMs`
27
+ * for one where the runtime connects (`connectOrBusy`), and `connectTimeoutMs` elsewhere. Idle connections keep no
28
+ * process alive, so a command exits when its work is done even while nobody ends the pool, such as one that sent no
29
+ * query of its own after Better Auth's schema check.
23
30
  */
24
31
  const appPool = (pg, url, max = readDbConnections(globalThis.process?.env ?? {})) => {
25
32
  const pools = store.__protobaseAppPools ??= /* @__PURE__ */ new Map();
@@ -32,7 +39,7 @@ const appPool = (pg, url, max = readDbConnections(globalThis.process?.env ?? {})
32
39
  const pool = handleDroppedConnections(new pg.Pool({
33
40
  connectionString: url,
34
41
  max,
35
- connectionTimeoutMillis: poolWaitMs,
42
+ connectionTimeoutMillis: connectTimeoutMs,
36
43
  allowExitOnIdle: true,
37
44
  types: textDates(pg)
38
45
  }));
@@ -57,4 +64,4 @@ const longQueryPool = (pg, url) => handleDroppedConnections(new pg.Pool({
57
64
  types: textDates(pg)
58
65
  }));
59
66
  //#endregion
60
- export { appPool, longQueryPool, poolWaitMs, readDbConnections };
67
+ export { appPool, connectTimeoutMs, longQueryPool, poolWaitMs, readDbConnections };
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.66.4";
2
+ var version = "0.66.6";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.66.4",
3
+ "version": "0.66.6",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,9 +43,9 @@
43
43
  "@better-auth/sso": "^1.7.12",
44
44
  "@livekit/protocol": "1.53.1",
45
45
  "@modelcontextprotocol/server": "^2.3.1",
46
- "@protobase/layout": "0.66.4",
47
- "@protobase/query": "0.66.4",
48
- "@protobase/schema": "0.66.4",
46
+ "@protobase/layout": "0.66.6",
47
+ "@protobase/query": "0.66.6",
48
+ "@protobase/schema": "0.66.6",
49
49
  "@react-email/render": "^2.1.0",
50
50
  "@react-pdf/primitives": "^4.4.0",
51
51
  "@react-pdf/renderer": "^4.9.0",