@lenne.tech/nest-server 12.6.17 → 12.6.19

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.
@@ -622,7 +622,10 @@ statements run in the session the framework set up (strict mode, UTC). On MongoD
622
622
  `mysql2`'s client-side escaping (`sql-escaper`), and `/iam/update-user` accepts any JSON for `name` and `image`. From
623
623
  `sql-escaper` 1.5.1 on, an object turns into `key = value` pairs only after a bare `SET ?`, which Kysely never writes
624
624
  (it writes `col = ?`); before that, `{"name": {"roles": "[\"admin\"]"}}` assigned `roles` — a signed-in user making
625
- themselves an administrator. The peer range (`>= 3.24.6`) guarantees the fixed escaper; never lower it.
625
+ themselves an administrator. The peer range (`>= 3.24.6`; `>= 3.25.0` since 12.6.18, for GHSA-f763-mv98-7rv9)
626
+ guarantees the fixed escaper; never lower it. mysql2 3.26.0 refuses `caching_sha2_password` (MySQL 8.4's default)
627
+ over a connection without TLS unless `allowPublicKeyRetrieval` or `serverPublicKey` is set
628
+ (`PUBLIC_KEY_RETRIEVAL_NOT_ALLOWED`, measured 2026-12-04); raising the floor to it needs that decision first.
626
629
 
627
630
  **Sign-up holds a pool connection while it hashes (accepted).** Better-Auth runs its Kysely adapter with transactions
628
631
  on a `pg` pool, and `/sign-up/email` hashes the password inside its transaction — on the framework's application pool
package/FRAMEWORK-API.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lenne.tech/nest-server — Framework API Reference
2
2
 
3
- > Auto-generated from source code as of 2026-12-02 (v12.6.17)
3
+ > Auto-generated from source code as of 2026-12-04 (v12.6.19)
4
4
  > File: `FRAMEWORK-API.md` — compact, machine-readable API surface for Claude Code
5
5
 
6
6
  ## CoreModule.forRoot()
@@ -1,5 +1,11 @@
1
1
  import { DiskHealthIndicator, HealthCheckResult, HealthCheckService, HealthIndicatorService, MemoryHealthIndicator, MongooseHealthIndicator } from '@nestjs/terminus';
2
2
  import { ConfigService } from '../../common/services/config.service.js';
3
+ export declare const DEFAULT_DATABASE_PING_TIMEOUT_MS = 2000;
4
+ export interface IHealthCheckMongoConnection {
5
+ db?: {
6
+ command(command: Record<string, unknown>): Promise<unknown>;
7
+ } | null;
8
+ }
3
9
  export declare class CoreHealthCheckService {
4
10
  protected config: ConfigService;
5
11
  protected db: MongooseHealthIndicator | null;
@@ -8,5 +14,7 @@ export declare class CoreHealthCheckService {
8
14
  protected memory: MemoryHealthIndicator;
9
15
  protected indicators?: HealthIndicatorService;
10
16
  constructor(config: ConfigService, db: MongooseHealthIndicator | null, disk: DiskHealthIndicator, health: HealthCheckService, memory: MemoryHealthIndicator, indicators?: HealthIndicatorService);
17
+ protected mongoConnection?: IHealthCheckMongoConnection | null;
11
18
  healthCheck(): Promise<HealthCheckResult>;
19
+ protected pingMongoDb(connection: IHealthCheckMongoConnection): Promise<void>;
12
20
  }
@@ -13,8 +13,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  import { Inject, Injectable, Optional } from '@nestjs/common';
14
14
  import { DiskHealthIndicator, HealthCheckService, HealthIndicatorService, MemoryHealthIndicator, MongooseHealthIndicator, } from '@nestjs/terminus';
15
15
  import { getBuildInfo } from '../../common/helpers/meta.helper.js';
16
+ import { InjectConnection } from '../../common/persistence/mongo/mongoose-compat.js';
16
17
  import { getPersistenceRuntime } from '../../common/persistence/persistence-runtime.registry.js';
17
18
  import { ConfigService } from '../../common/services/config.service.js';
19
+ export const DEFAULT_DATABASE_PING_TIMEOUT_MS = 2000;
18
20
  let CoreHealthCheckService = class CoreHealthCheckService {
19
21
  config;
20
22
  db;
@@ -30,18 +32,28 @@ let CoreHealthCheckService = class CoreHealthCheckService {
30
32
  this.memory = memory;
31
33
  this.indicators = indicators;
32
34
  }
35
+ mongoConnection;
33
36
  healthCheck() {
34
37
  const healthIndicatorFunctions = [];
35
38
  if (this.db && this.config.get('healthCheck.configs.database.enabled')) {
39
+ const db = this.db;
36
40
  healthIndicatorFunctions.push(() => {
37
- const { timeout, ...options } = this.config.get('healthCheck.configs.database.options') ?? { timeout: 300 };
38
- const attempt = this.db.pingCheck(this.config.get('healthCheck.configs.database.key') ?? 'database', options);
39
- return timeout === undefined ? attempt : attempt.withTimeout(timeout);
41
+ const { connection, timeout = DEFAULT_DATABASE_PING_TIMEOUT_MS, ...options } = this.config.get('healthCheck.configs.database.options') ?? {};
42
+ const key = this.config.get('healthCheck.configs.database.key') ?? 'database';
43
+ const target = connection ?? this.mongoConnection;
44
+ if (!this.indicators || !target) {
45
+ return db.pingCheck(key, { connection, ...options }).withTimeout(timeout);
46
+ }
47
+ return this.indicators
48
+ .check(key)
49
+ .attempt(() => this.pingMongoDb(target))
50
+ .withTimeout(timeout);
40
51
  });
41
52
  }
42
53
  if (this.config.get('healthCheck.configs.database.enabled')) {
43
54
  const key = this.config.get('healthCheck.configs.database.key') ?? 'database';
44
- const timeout = this.config.get('healthCheck.configs.database.options')?.timeout ?? 1000;
55
+ const timeout = this.config.get('healthCheck.configs.database.options')?.timeout ??
56
+ DEFAULT_DATABASE_PING_TIMEOUT_MS;
45
57
  for (const source of getPersistenceRuntime()?.sqlSources() ?? []) {
46
58
  if (this.indicators) {
47
59
  healthIndicatorFunctions.push(() => this.indicators
@@ -69,7 +81,18 @@ let CoreHealthCheckService = class CoreHealthCheckService {
69
81
  }
70
82
  return this.health.check(healthIndicatorFunctions);
71
83
  }
84
+ async pingMongoDb(connection) {
85
+ if (!connection.db) {
86
+ throw new Error('Not connected to database');
87
+ }
88
+ await connection.db.command({ ping: 1 });
89
+ }
72
90
  };
91
+ __decorate([
92
+ Optional(),
93
+ InjectConnection(),
94
+ __metadata("design:type", Object)
95
+ ], CoreHealthCheckService.prototype, "mongoConnection", void 0);
73
96
  CoreHealthCheckService = __decorate([
74
97
  Injectable(),
75
98
  __param(1, Inject(MongooseHealthIndicator)),
@@ -1 +1 @@
1
- {"version":3,"file":"core-health-check.service.js","sourceRoot":"","sources":["../../../../src/core/modules/health-check/core-health-check.service.ts"],"names":[],"mappings":";;;;;;;;;;;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,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;IAI/B,WAAA,QAAQ,EAAE,CAAA;qCANO,aAAa;QAEgB,uBAAuB;QACtD,mBAAmB;QACjB,kBAAkB;QAClB,qBAAqB;QACJ,sBAAsB;GARhD,sBAAsB,CA2FlC"}
1
+ {"version":3,"file":"core-health-check.service.js","sourceRoot":"","sources":["../../../../src/core/modules/health-check/core-health-check.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,mBAAmB,EAGnB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,GAExB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0DAA0D,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAWxE,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,CAAC;AAY9C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAErB;IAEiC;IACjC;IACA;IACA;IACY;IAPxB,YACY,MAAqB,EAEY,EAAkC,EACnE,IAAyB,EACzB,MAA0B,EAC1B,MAA6B,EACjB,UAAmC;QAN/C,WAAM,GAAN,MAAM,CAAe;QAEY,OAAE,GAAF,EAAE,CAAgC;QACnE,SAAI,GAAJ,IAAI,CAAqB;QACzB,WAAM,GAAN,MAAM,CAAoB;QAC1B,WAAM,GAAN,MAAM,CAAuB;QACjB,eAAU,GAAV,UAAU,CAAyB;IACxD,CAAC;IAQM,eAAe,CAAsC;IAE/D,WAAW;QACT,MAAM,wBAAwB,GAAG,EAAE,CAAC;QAEpC,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,G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IlC"}
@@ -0,0 +1,80 @@
1
+ # Migration Guide: 12.6.17 → 12.6.18
2
+
3
+ ## Overview
4
+
5
+ | Category | Details |
6
+ |---|---|
7
+ | **Breaking Changes** | None. The `mysql2` peer range starts at 3.25.0 instead of 3.24.6 (§2) |
8
+ | **New Features** | None |
9
+ | **Bugfixes** | None |
10
+ | **Security** | undici 7.30.5 (13 advisories of 2026-12-04 on 7.30.2, seven high) and nodemailer 10.6.3 (GHSA-w5r8-mmxv-957g) (§1); mysql2 3.25.0 clears GHSA-f763-mv98-7rv9 (high) (§2) |
11
+ | **Migration Effort** | None for an npm-mode project. A project on MySQL raises its own `mysql2` to 3.25.0. A project that installs with `--frozen-lockfile` before 2026-12-05 13:05 UTC adds one `minimumReleaseAgeExclude` entry (§1) |
12
+
13
+ ## Quick Migration
14
+
15
+ ```bash
16
+ pnpm add @lenne.tech/nest-server@12.6.18
17
+ pnpm run update # nest-server-starter based projects: raises the project's mysql2 to 3.25.0
18
+ pnpm audit
19
+ pnpm run build
20
+ pnpm test
21
+ ```
22
+
23
+ **Vendor mode**: run `/lt-dev:backend:update-nest-server-core` as usual, then raise the project's own `undici` to
24
+ 7.30.5 and `nodemailer` to 10.6.3 (and `mysql2` to 3.25.0 on MySQL): in vendor mode they are the project's
25
+ dependencies.
26
+
27
+ ## 1. Security: undici 7.30.5 and nodemailer 10.6.3
28
+
29
+ nodejs/undici published 13 advisories for the 7.x line on 2026-12-04; all of them cover the 7.30.2 that 12.6.17
30
+ ships, seven are high, and all are fixed in 7.30.4 (7.30.5 adds only a RISC-V build fix). Among them:
31
+
32
+ - **GHSA-fgj4-8x8v-fqhm** (high): the redirect interceptor verified a cross-origin redirect target's certificate
33
+ against the first host's name.
34
+ - **GHSA-h5rf-4xrf-76mc** (high): an assertion in the HTTP/1.1 response parser ends the process from `request()`
35
+ and `fetch()`.
36
+
37
+ The framework uses undici for `outboundFetch()`, the guarded fetch for URLs users enter (webhooks, export targets).
38
+ nodemailer 10.6.3 closes **GHSA-w5r8-mmxv-957g** (moderate: `attachDataUrls` leaks inline images into later
39
+ messages). Both are repository advisories that GitHub's global database does not list yet, so `pnpm audit` does not
40
+ report them.
41
+
42
+ **undici 7.30.5 is younger than pnpm's default release-age window (24 hours) until 2026-12-05 13:05 UTC.** An
43
+ install that resolves anew warns and continues; an install with `--frozen-lockfile` (CI, Docker) refuses it until
44
+ then. Add the exact version to `pnpm-workspace.yaml` and remove the entry after that time:
45
+
46
+ ```yaml
47
+ minimumReleaseAgeExclude:
48
+ - 'undici@7.30.5' # nest-server 12.6.18, undici advisories of 2026-12-04; remove after 2026-12-05 13:05 UTC
49
+ ```
50
+
51
+ ## 2. Security: mysql2 at least 3.25.0
52
+
53
+ **Action needed** in every project on MySQL or MariaDB. `mysql2` is an optional peer: the project installs it, so
54
+ its own pin decides which version runs.
55
+
56
+ - **GHSA-f763-mv98-7rv9** (high, mysql2 <= 3.24.6): SQL injection when the server runs with
57
+ `NO_BACKSLASH_ESCAPES`. The framework's own session sets backslash escapes, so its statements are not affected; a
58
+ project's own pool or a changed `sql_mode` is.
59
+
60
+ 12.6.18 is tested against mysql2 3.25.0 and declares the peer range `>=3.25.0 <4`.
61
+
62
+ **Do not take mysql2 3.26 without TLS yet.** It closes two moderate advisories by refusing to fetch the server's RSA
63
+ key over a connection without TLS: on MySQL 8.4 (default `caching_sha2_password`) every connection without TLS then
64
+ fails with `PUBLIC_KEY_RETRIEVAL_NOT_ALLOWED` after a server restart. Connect over TLS (`?ssl=…` in the URL) or set
65
+ `?allowPublicKeyRetrieval=true` on a trusted network first. MariaDB is not affected.
66
+
67
+ ## Troubleshooting
68
+
69
+ | Symptom | Cause | Fix |
70
+ |---|---|---|
71
+ | `ERR_PNPM_NO_MATURE_MATCHING_VERSION` for `undici@7.30.5` | `--frozen-lockfile` install inside the 24-hour window (§1) | `minimumReleaseAgeExclude: ['undici@7.30.5']`, removed after 2026-12-05 13:05 UTC |
72
+ | `unmet peer mysql2@">=3.25.0 <4"` warning | the project pins mysql2 3.24.x or older (§2) | `pnpm run update`, or `pnpm add mysql2@3.25.0` |
73
+ | `PUBLIC_KEY_RETRIEVAL_NOT_ALLOWED` | mysql2 3.26 on MySQL 8.4 without TLS (§2) | stay on 3.25.0, or connect over TLS |
74
+
75
+ ## Module Documentation
76
+
77
+ - [undici security advisories](https://github.com/nodejs/undici/security/advisories)
78
+ - [GHSA-w5r8-mmxv-957g](https://github.com/nodemailer/nodemailer/security/advisories/GHSA-w5r8-mmxv-957g)
79
+ - [GHSA-f763-mv98-7rv9](https://github.com/sidorares/node-mysql2/security/advisories/GHSA-f763-mv98-7rv9)
80
+ - `.claude/rules/persistence.md`: the SQL drivers are optional peers
@@ -0,0 +1,53 @@
1
+ # Migration Guide: 12.6.18 → 12.6.19
2
+
3
+ ## Overview
4
+
5
+ | Category | Details |
6
+ |---|---|
7
+ | **Breaking Changes** | None. Changed defaults: the MongoDB health check pings instead of reading `readyState`, the database ping waits up to 2000 ms (§1) |
8
+ | **New Features** | None |
9
+ | **Bugfixes** | The health check reported a reachable MongoDB replica set as down whenever the driver briefly saw no primary (§1) |
10
+ | **Migration Effort** | None |
11
+
12
+ ## Quick Migration
13
+
14
+ ```bash
15
+ pnpm add @lenne.tech/nest-server@12.6.19
16
+ pnpm run build
17
+ pnpm test
18
+ ```
19
+
20
+ **Vendor mode**: run `/lt-dev:backend:update-nest-server-core` as usual.
21
+
22
+ ## 1. Health check: the MongoDB check pings, and waits up to 2000 ms
23
+
24
+ The MongoDB check of `GET /health-check` used Terminus' `MongooseHealthIndicator`, which answers "down" BEFORE it
25
+ pings whenever the Mongoose connection's `readyState` is not 1. Mongoose sets `disconnected` as soon as the driver's
26
+ topology briefly sees no primary: a replica set without `ReplicaSetWithPrimary`, a single server turning `Unknown`.
27
+ One lost heartbeat is enough, while the database answers in milliseconds and the application's own queries simply
28
+ wait for the driver's server selection. On a cluster with managed MongoDB replica sets this gate caused far more
29
+ than 95 % of all "database down" alarms, and three in a row took the pod out of the readiness rotation.
30
+
31
+ The core now sends a real `ping` (`CoreHealthCheckService.pingMongoDb()`) without that gate. It waits for the
32
+ driver's server selection like any query, so the check reports down only when the database does not answer within
33
+ the timeout, or when the initial connect has not finished yet.
34
+
35
+ The timeout is now **2000 ms** for the MongoDB ping and for every SQL source, unless
36
+ `healthCheck.configs.database.options.timeout` sets another value (exported as `DEFAULT_DATABASE_PING_TIMEOUT_MS`).
37
+ Before, MongoDB waited 300 ms without configured options and 1000 ms with options but no `timeout`; SQL sources
38
+ waited 1000 ms. The longer budget gives server selection time to find the primary again.
39
+
40
+ **Check:** nothing to change. Keep your probe timeout above 2 s. A subclass of `CoreHealthCheckService` keeps the new
41
+ check; one that builds its own MongoDB indicator with `this.db.pingCheck()` keeps Terminus' gate. To keep the old
42
+ timeout, set `healthCheck.configs.database.options.timeout: 300`.
43
+
44
+ ## 2. Audit: minimatch 11.0.10
45
+
46
+ GHSA-3924-r96c-gp9w (low, minimatch 11.0.6 to 11.0.9) reached GitHub's global database on 2026-12-04, so `pnpm audit`
47
+ fails on glob 14's minimatch 11.0.8 (via rimraf, dev tooling). nest-server overrides it to 11.0.10; that override does
48
+ not reach your project. Where `pnpm audit` reports it, add `'minimatch@>=11.0.0 <11.0.10': '11.0.10'` to `overrides` in
49
+ your `pnpm-workspace.yaml` (nest-server-starter has it).
50
+
51
+ ## Module Documentation
52
+
53
+ - `src/core/modules/health-check/core-health-check.service.ts`: `pingMongoDb()`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "12.6.17",
3
+ "version": "12.6.19",
4
4
  "type": "module",
5
5
  "description": "Server framework in TypeScript on top of NestJS: GraphQL and REST APIs on MongoDB, PostgreSQL, MySQL or MariaDB, with authentication, field-level permissions, multi-tenancy, offline sync and an AI assistant.",
6
6
  "keywords": [
@@ -141,7 +141,7 @@
141
141
  "lodash": "4.18.1",
142
142
  "multer": "2.5.0",
143
143
  "node-mailjet": "6.0.11",
144
- "nodemailer": "10.4.1",
144
+ "nodemailer": "10.6.3",
145
145
  "object-path": "0.11.8",
146
146
  "passport": "0.7.0",
147
147
  "passport-jwt": "4.0.1",
@@ -150,7 +150,7 @@
150
150
  "rxjs": "7.8.2",
151
151
  "supertest": "7.3.1",
152
152
  "ts-morph": "28.0.0",
153
- "undici": "7.30.2",
153
+ "undici": "7.30.5",
154
154
  "ws": "8.23.0",
155
155
  "yuml-diagram": "1.2.0"
156
156
  },
@@ -170,7 +170,7 @@
170
170
  "kysely": ">=0.29.0 <0.30.0",
171
171
  "mongodb": ">=7.8.0 <8",
172
172
  "mongoose": ">=9.12.2 <10",
173
- "mysql2": ">=3.24.6 <4",
173
+ "mysql2": ">=3.25.0 <4",
174
174
  "pg": ">=8.23.0 <9",
175
175
  "typeorm": ">=1.1.0 <2"
176
176
  },
@@ -265,7 +265,7 @@
265
265
  "kysely": "0.29.8",
266
266
  "mongodb": "7.8.0",
267
267
  "mongoose": "9.12.3",
268
- "mysql2": "3.24.6",
268
+ "mysql2": "3.25.0",
269
269
  "nodemon": "3.1.14",
270
270
  "otpauth": "9.6.0",
271
271
  "oxfmt": "0.75.0",
@@ -274,7 +274,7 @@
274
274
  "pg": "8.23.1",
275
275
  "playwright-core": "1.64.1",
276
276
  "rimraf": "6.1.4",
277
- "smtp-server": "3.21.3",
277
+ "smtp-server": "3.21.9",
278
278
  "tsx": "4.23.15",
279
279
  "tus-js-client": "4.3.1",
280
280
  "typeorm": "1.1.2",
@@ -11,9 +11,26 @@ import {
11
11
  } from '@nestjs/terminus';
12
12
 
13
13
  import { getBuildInfo } from '../../common/helpers/meta.helper.js';
14
+ import { InjectConnection } from '../../common/persistence/mongo/mongoose-compat.js';
14
15
  import { getPersistenceRuntime } from '../../common/persistence/persistence-runtime.registry.js';
15
16
  import { ConfigService } from '../../common/services/config.service.js';
16
17
 
18
+ /**
19
+ * How long a database ping (MongoDB and every SQL source) may take before the health check reports the database as
20
+ * down, unless `healthCheck.configs.database.options.timeout` sets another value.
21
+ *
22
+ * 2 s, not the former 300 ms (MongoDB) / 1000 ms (SQL): the MongoDB ping waits for the driver's server selection
23
+ * (see {@link CoreHealthCheckService.pingMongoDb}), which rides out a replica set that briefly sees no primary; a
24
+ * single slow round trip to a managed database outside the cluster must not report it down either. 2 s still fails a
25
+ * database that does not answer and stays below the readiness probe timeout of the lt charts (3 s).
26
+ */
27
+ export const DEFAULT_DATABASE_PING_TIMEOUT_MS = 2000;
28
+
29
+ /** The part of a Mongoose connection the health check's MongoDB ping uses */
30
+ export interface IHealthCheckMongoConnection {
31
+ db?: { command(command: Record<string, unknown>): Promise<unknown> } | null;
32
+ }
33
+
17
34
  /**
18
35
  * Core health check service
19
36
  * Inspired by https://mobileappcircular.com/marketplace-backend-creating-a-health-check-endpoint-in-nestjs-app-using-terminus-25727e96c7d2
@@ -30,24 +47,39 @@ export class CoreHealthCheckService {
30
47
  @Optional() protected indicators?: HealthIndicatorService,
31
48
  ) {}
32
49
 
50
+ /**
51
+ * The application's Mongoose connection for the MongoDB ping (12.6.19); `null` where no MongoDB is configured.
52
+ * Injected as a property, so a project subclass with its own constructor receives it too.
53
+ */
54
+ @Optional()
55
+ @InjectConnection()
56
+ protected mongoConnection?: IHealthCheckMongoConnection | null;
57
+
33
58
  healthCheck(): Promise<HealthCheckResult> {
34
59
  const healthIndicatorFunctions = [];
35
60
  // The MongoDB ping where MongoDB is configured — a project on PostgreSQL alone has no MongoDB to ping
36
61
  if (this.db && this.config.get<boolean>('healthCheck.configs.database.enabled')) {
62
+ const db = this.db;
37
63
  healthIndicatorFunctions.push(() => {
38
64
  // `timeout` stays part of the config contract, but @nestjs/terminus 12 deprecated it on the
39
65
  // indicator in favour of `.withTimeout()` on the returned attempt — translate it here, so the
40
66
  // configuration keeps working once the option is gone from the indicator.
41
- // Same effective timeouts as before: 300 ms without configured options, otherwise the
42
- // configured `timeout`, otherwise Terminus' own default (1000 ms).
43
- const { timeout, ...options } = this.config.get<MongoosePingCheckSettings>(
44
- 'healthCheck.configs.database.options',
45
- ) ?? { timeout: 300 };
46
- const attempt = this.db.pingCheck(
47
- this.config.get<string>('healthCheck.configs.database.key') ?? 'database',
48
- options,
49
- );
50
- return timeout === undefined ? attempt : attempt.withTimeout(timeout);
67
+ const {
68
+ connection,
69
+ timeout = DEFAULT_DATABASE_PING_TIMEOUT_MS,
70
+ ...options
71
+ } = this.config.get<MongoosePingCheckSettings>('healthCheck.configs.database.options') ?? {};
72
+ const key = this.config.get<string>('healthCheck.configs.database.key') ?? 'database';
73
+ const target: IHealthCheckMongoConnection | null | undefined = connection ?? this.mongoConnection;
74
+ if (!this.indicators || !target) {
75
+ // A subclass constructed without the HealthIndicatorService, or without the injected connection: Terminus'
76
+ // own check, with its readyState gate (see pingMongoDb)
77
+ return db.pingCheck(key, { connection, ...options }).withTimeout(timeout);
78
+ }
79
+ return this.indicators
80
+ .check(key)
81
+ .attempt(() => this.pingMongoDb(target))
82
+ .withTimeout(timeout);
51
83
  });
52
84
  }
53
85
  if (this.config.get<boolean>('healthCheck.configs.database.enabled')) {
@@ -55,7 +87,8 @@ export class CoreHealthCheckService {
55
87
  // database the application cannot reach is down, whichever one it is
56
88
  const key = this.config.get<string>('healthCheck.configs.database.key') ?? 'database';
57
89
  const timeout =
58
- this.config.get<MongoosePingCheckSettings>('healthCheck.configs.database.options')?.timeout ?? 1000;
90
+ this.config.get<MongoosePingCheckSettings>('healthCheck.configs.database.options')?.timeout ??
91
+ DEFAULT_DATABASE_PING_TIMEOUT_MS;
59
92
  for (const source of getPersistenceRuntime()?.sqlSources() ?? []) {
60
93
  if (this.indicators) {
61
94
  healthIndicatorFunctions.push(() =>
@@ -110,4 +143,25 @@ export class CoreHealthCheckService {
110
143
 
111
144
  return this.health.check(healthIndicatorFunctions);
112
145
  }
146
+
147
+ /**
148
+ * Pings the MongoDB the application uses (12.6.19): a real `ping` command, bounded by the check's timeout.
149
+ *
150
+ * Deliberately WITHOUT the `readyState` gate of Terminus' `MongooseHealthIndicator`, which reports "down" before it
151
+ * pings whenever the connection's `readyState` is not 1. Mongoose sets `disconnected` as soon as the driver's
152
+ * topology briefly sees no primary (a replica set without `ReplicaSetWithPrimary`, a single server turning
153
+ * `Unknown`): one lost heartbeat is enough, while the database answers in milliseconds and the application's own
154
+ * queries just wait for the driver's server selection. On a cluster with managed MongoDB replica sets that gate
155
+ * produced far more than 95 % of all "database down" alarms. Here the ping waits for server selection the same way,
156
+ * so the check reports down only when the database does not answer within the timeout.
157
+ *
158
+ * @param connection The Mongoose connection (`healthCheck.configs.database.options.connection` or the injected one)
159
+ */
160
+ protected async pingMongoDb(connection: IHealthCheckMongoConnection): Promise<void> {
161
+ if (!connection.db) {
162
+ // Not connected yet (the initial connect is still running) or never connected
163
+ throw new Error('Not connected to database');
164
+ }
165
+ await connection.db.command({ ping: 1 });
166
+ }
113
167
  }