pgserve 2.1.0 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgserve",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Embedded PostgreSQL server with true concurrent connections - zero config, auto-provision databases",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -47,8 +47,13 @@ const DEFAULT_PORT = 8432;
47
47
  * Revised defaults:
48
48
  * - 4G memory ceiling — covers realistic load while still bounded so
49
49
  * a runaway query can't eat the host.
50
- * - 50 max restarts BUT only counted when min_uptime < 10s ("rapid"
51
- * failures). Healthy long-uptime crashes don't count against the cap.
50
+ * - 50 max restarts. Earlier drafts paired this with `--min-uptime` to
51
+ * only count rapid failures, but pm2 6.0 dropped `--min-uptime` from
52
+ * the CLI surface (it survives only inside ecosystem files now). We
53
+ * keep the budget generous enough that occasional long-uptime crashes
54
+ * don't burn through it; if you observe restart-budget exhaustion
55
+ * from non-rapid crashes, raise `maxRestarts` rather than reintroducing
56
+ * `--min-uptime` (which would break install on pm2 6.x).
52
57
  * - Exponential backoff on repeated failures (100ms → 60s) so we don't
53
58
  * hammer on persistent issues.
54
59
  * - 60s graceful shutdown window — Postgres needs time to flush WAL.
@@ -62,7 +67,6 @@ const DEFAULT_PORT = 8432;
62
67
  */
63
68
  const HARDENED_DEFAULTS = {
64
69
  maxRestarts: 50,
65
- minUptimeMs: 10_000,
66
70
  restartDelayMs: 4000,
67
71
  expBackoffRestartDelayMs: 100,
68
72
  // pm2 caps `--exp-backoff-restart-delay` ramp at the current backoff
@@ -149,11 +153,14 @@ function buildPm2StartArgs({ scriptPath, port, dataDir }) {
149
153
  'none',
150
154
  '--max-restarts',
151
155
  String(HARDENED_DEFAULTS.maxRestarts),
152
- // `--min-uptime` makes `--max-restarts` count only RAPID failures
153
- // (process crashed within N ms of starting). Healthy long-uptime
154
- // crashes don't burn the budget.
155
- '--min-uptime',
156
- String(HARDENED_DEFAULTS.minUptimeMs),
156
+ // NOTE: pm2 ≥ 6.0 dropped `--min-uptime` from the CLI surface passing
157
+ // it produces `error: unknown option --min-uptime` and aborts the
158
+ // install. The flag still works inside an ecosystem file, but per the
159
+ // canonical-pm2-supervision wish we keep `pgserve install` as a pure
160
+ // CLI flow (no extra files for operators to manage). The trade-off is
161
+ // that `--max-restarts` now counts every restart (rapid or not) rather
162
+ // than only sub-`min_uptime` ones; the budget of 50 above is sized
163
+ // accordingly.
157
164
  '--restart-delay',
158
165
  String(HARDENED_DEFAULTS.restartDelayMs),
159
166
  // Exponential backoff between successive failures: starts at 100ms,
@@ -124,7 +124,12 @@ describe('pgserve install', () => {
124
124
  expect(startCall).toContain('pgserve');
125
125
  expect(startCall).toContain('--max-restarts');
126
126
  expect(startCall).toContain('50');
127
- expect(startCall).toContain('--min-uptime');
127
+ // pm2 ≥ 6.0 dropped `--min-uptime` from the CLI surface — it now lives
128
+ // only inside ecosystem files. Passing it on the command line aborts
129
+ // `pm2 start` with `error: unknown option --min-uptime`. Lock that out:
130
+ // `pgserve install` must NOT pass `--min-uptime` so it stays compatible
131
+ // across pm2 5.x → 6.x. See cli-install.cjs:HARDENED_DEFAULTS.
132
+ expect(startCall).not.toContain('--min-uptime');
128
133
  expect(startCall).toContain('--exp-backoff-restart-delay');
129
134
  expect(startCall).toContain('--max-memory-restart');
130
135
  expect(startCall).toContain('4G');