@open-mercato/cli 0.6.2-develop.3461.1.605f31c2c9 → 0.6.2

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.
@@ -809,6 +809,8 @@ async function writeEphemeralEnvironmentState(input2) {
809
809
  status: "running",
810
810
  baseUrl: input2.baseUrl,
811
811
  port: input2.port,
812
+ databaseUrl: input2.databaseUrl,
813
+ queueBaseDir: input2.queueBaseDir,
812
814
  source: input2.logPrefix,
813
815
  captureScreenshots: input2.captureScreenshots,
814
816
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -849,6 +851,12 @@ async function readEphemeralEnvironmentState() {
849
851
  if (typeof record.port !== "number" || !Number.isFinite(record.port) || record.port < 1) {
850
852
  return null;
851
853
  }
854
+ if (typeof record.databaseUrl !== "string" || record.databaseUrl.length === 0) {
855
+ return null;
856
+ }
857
+ if (typeof record.queueBaseDir !== "string" || record.queueBaseDir.length === 0) {
858
+ return null;
859
+ }
852
860
  if (typeof record.source !== "string" || record.source.length === 0) {
853
861
  return null;
854
862
  }
@@ -862,6 +870,8 @@ async function readEphemeralEnvironmentState() {
862
870
  status: "running",
863
871
  baseUrl: record.baseUrl,
864
872
  port: record.port,
873
+ databaseUrl: record.databaseUrl,
874
+ queueBaseDir: record.queueBaseDir,
865
875
  source: record.source,
866
876
  captureScreenshots: record.captureScreenshots,
867
877
  startedAt: record.startedAt
@@ -1183,9 +1193,10 @@ async function acquireEphemeralRuntimeLock(logPrefix, options = {}) {
1183
1193
  }
1184
1194
  };
1185
1195
  }
1186
- function buildReusableEnvironment(baseUrl, captureScreenshots) {
1196
+ function buildReusableEnvironment(baseUrl, databaseUrl, queueBaseDir, captureScreenshots) {
1187
1197
  const enterpriseModulesFlag = process.env.OM_ENABLE_ENTERPRISE_MODULES ?? "false";
1188
1198
  return buildEnvironment({
1199
+ DATABASE_URL: databaseUrl,
1189
1200
  BASE_URL: baseUrl,
1190
1201
  APP_URL: baseUrl,
1191
1202
  NEXT_PUBLIC_APP_URL: baseUrl,
@@ -1208,6 +1219,7 @@ function buildReusableEnvironment(baseUrl, captureScreenshots) {
1208
1219
  TENANT_DATA_ENCRYPTION_FALLBACK_KEY: process.env.TENANT_DATA_ENCRYPTION_FALLBACK_KEY ?? "om-ephemeral-integration-fallback-key",
1209
1220
  OM_CLI_QUIET: "1",
1210
1221
  MERCATO_QUIET: "1",
1222
+ QUEUE_BASE_DIR: queueBaseDir,
1211
1223
  NODE_NO_WARNINGS: "1",
1212
1224
  PW_CAPTURE_SCREENSHOTS: captureScreenshots ? "1" : "0"
1213
1225
  });
@@ -1258,8 +1270,13 @@ async function tryReuseExistingEnvironment(options) {
1258
1270
  return {
1259
1271
  baseUrl: state.baseUrl,
1260
1272
  port: state.port,
1261
- databaseUrl: "",
1262
- commandEnvironment: buildReusableEnvironment(state.baseUrl, state.captureScreenshots),
1273
+ databaseUrl: state.databaseUrl,
1274
+ commandEnvironment: buildReusableEnvironment(
1275
+ state.baseUrl,
1276
+ state.databaseUrl,
1277
+ state.queueBaseDir,
1278
+ state.captureScreenshots
1279
+ ),
1263
1280
  ownedByCurrentProcess: false,
1264
1281
  stop: async () => {
1265
1282
  }
@@ -2292,10 +2309,19 @@ async function startEphemeralEnvironment(options) {
2292
2309
  JWT_SECRET: process.env.JWT_SECRET ?? "om-ephemeral-integration-jwt-secret",
2293
2310
  OM_SECURITY_MFA_SETUP_SECRET: process.env.OM_SECURITY_MFA_SETUP_SECRET ?? "om-ephemeral-integration-mfa-setup-secret",
2294
2311
  NODE_ENV: "production",
2295
- DB_POOL_MIN: "0",
2296
- DB_POOL_MAX: "5",
2297
- DB_POOL_IDLE_TIMEOUT: "1000",
2298
- DB_POOL_ACQUIRE_TIMEOUT: "10000",
2312
+ // Pool sizing for the ephemeral integration runtime. Defaults were once
2313
+ // very aggressive (max=5, idle=1000) which exposed flaky 'timeout exceeded
2314
+ // when trying to connect' errors on `progressService.createJob`-backed
2315
+ // endpoints (sync_excel.import, data_sync.run, progress.jobs) — each
2316
+ // request acquires a transaction connection plus a separate connection
2317
+ // for the encryption subscriber's fetchMap probe, and with 1s idle close
2318
+ // the pool thrashes faster than pg-pool can repopulate. These values
2319
+ // still keep the pool tighter than production but give enough headroom
2320
+ // for the legitimate query bursts.
2321
+ DB_POOL_MIN: "2",
2322
+ DB_POOL_MAX: "20",
2323
+ DB_POOL_IDLE_TIMEOUT: "10000",
2324
+ DB_POOL_ACQUIRE_TIMEOUT: "15000",
2299
2325
  DB_IDLE_SESSION_TIMEOUT_MS: "30000",
2300
2326
  DB_IDLE_IN_TRANSACTION_TIMEOUT_MS: "30000",
2301
2327
  OM_INTEGRATION_TEST: "true",
@@ -2423,6 +2449,8 @@ async function startEphemeralEnvironment(options) {
2423
2449
  await writeEphemeralEnvironmentState({
2424
2450
  baseUrl: applicationBaseUrl,
2425
2451
  port: applicationPort,
2452
+ databaseUrl,
2453
+ queueBaseDir: EPHEMERAL_QUEUE_BASE_DIR,
2426
2454
  logPrefix: options.logPrefix,
2427
2455
  captureScreenshots: options.captureScreenshots
2428
2456
  });