@steve31415/baselib 3.0.0 → 3.0.1

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.
package/dist/db.d.ts CHANGED
@@ -4,6 +4,10 @@ export interface PoolOptions {
4
4
  /** Override the database name (default: env DB_NAME / DATABASE_URL path). */
5
5
  database?: string;
6
6
  max?: number;
7
+ /** How long a checkout waits for a free connection before failing (pg's
8
+ * default is to wait forever, which turns pool starvation into a silent
9
+ * hang instead of an error). */
10
+ connectionTimeoutMillis?: number;
7
11
  /** Receives idle-client errors (see logPoolErrors). Without one they go to
8
12
  * stderr — on the Cloud Logging backstop, but not in Axiom. */
9
13
  logger?: Logger;
package/dist/db.js CHANGED
@@ -49,12 +49,13 @@ async function newPool(opts) {
49
49
  user: requireEnv('DB_IAM_USER'),
50
50
  database: opts.database ?? requireEnv('DB_NAME'),
51
51
  max: opts.max ?? 3, // shared instance: default max_connections is low
52
+ connectionTimeoutMillis: opts.connectionTimeoutMillis,
52
53
  });
53
54
  }
54
55
  const url = new URL(requireEnv('DATABASE_URL'));
55
56
  if (opts.database)
56
57
  url.pathname = `/${opts.database}`;
57
- return new pg.Pool({ connectionString: url.toString(), max: opts.max ?? 5 });
58
+ return new pg.Pool({ connectionString: url.toString(), max: opts.max ?? 5, connectionTimeoutMillis: opts.connectionTimeoutMillis });
58
59
  }
59
60
  /** End a pool and resolve only once every client's connection has actually
60
61
  * closed. pg-pool's own `end()` resolves as soon as it has *asked* its idle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steve31415/baselib",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Plasticine new-world shared platform library: logging, auth, service-to-service auth, db, HTTP, sync, app updates",
5
5
  "type": "module",
6
6
  "license": "MIT",