whitelabel-db 1.8.0 → 1.8.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.
@@ -4,5 +4,16 @@ export interface ConnectionDetails {
4
4
  username: string;
5
5
  password: string;
6
6
  dbname: string;
7
+ /**
8
+ * Optional connection-pool overrides. Defaults (max 20 / acquire 30s) are
9
+ * sized for crawler bursts against the SSR path; callers can tune per env
10
+ * without another release (WL-126).
11
+ */
12
+ pool?: {
13
+ max?: number;
14
+ min?: number;
15
+ acquire?: number;
16
+ idle?: number;
17
+ };
7
18
  }
8
19
  export declare const connect: (connectionDetails: ConnectionDetails) => Promise<Sequelize>;
@@ -44,7 +44,7 @@ const LoyaltyProgramTier_1 = require("../models/LoyaltyProgramTier");
44
44
  const BookingLoyaltyRecord_1 = require("../models/BookingLoyaltyRecord");
45
45
  const migration_1 = require("./migration");
46
46
  const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, function* () {
47
- var _a;
47
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
48
48
  const connection = new sequelize_typescript_1.Sequelize({
49
49
  dialect: 'postgres',
50
50
  host: connectionDetails.host,
@@ -52,6 +52,16 @@ const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, functio
52
52
  password: connectionDetails.password,
53
53
  database: connectionDetails.dbname,
54
54
  logging: false,
55
+ // Connection pool. Without this Sequelize defaults to max 5, which the
56
+ // per-worker SSR path exhausts under crawler bursts -> acquire timeouts ->
57
+ // 5xx (WL-126). acquire (30s) is intentionally below the load balancer's
58
+ // idle timeout so callers return a controlled 503 before the LB emits 502.
59
+ pool: {
60
+ max: (_b = (_a = connectionDetails.pool) === null || _a === void 0 ? void 0 : _a.max) !== null && _b !== void 0 ? _b : 20,
61
+ min: (_d = (_c = connectionDetails.pool) === null || _c === void 0 ? void 0 : _c.min) !== null && _d !== void 0 ? _d : 2,
62
+ acquire: (_f = (_e = connectionDetails.pool) === null || _e === void 0 ? void 0 : _e.acquire) !== null && _f !== void 0 ? _f : 30000,
63
+ idle: (_h = (_g = connectionDetails.pool) === null || _g === void 0 ? void 0 : _g.idle) !== null && _h !== void 0 ? _h : 10000,
64
+ },
55
65
  models: [
56
66
  User_1.User,
57
67
  Agency_1.Agency,
@@ -108,7 +118,7 @@ const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, functio
108
118
  // a separate index on them will fail
109
119
  const errorMessage = (syncError === null || syncError === void 0 ? void 0 : syncError.message) || '';
110
120
  const errorSql = (syncError === null || syncError === void 0 ? void 0 : syncError.sql) || '';
111
- const originalCode = ((_a = syncError === null || syncError === void 0 ? void 0 : syncError.original) === null || _a === void 0 ? void 0 : _a.code) || '';
121
+ const originalCode = ((_j = syncError === null || syncError === void 0 ? void 0 : syncError.original) === null || _j === void 0 ? void 0 : _j.code) || '';
112
122
  if ((errorMessage.includes('already exists') &&
113
123
  errorSql.includes('CREATE INDEX')) ||
114
124
  originalCode === '42P07' || // duplicate_table
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whitelabel-db",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",