@lenne.tech/nest-server 11.46.9 → 11.46.11
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/FRAMEWORK-API.md +1 -1
- package/dist/core/modules/health-check/core-health-check.service.d.ts +12 -0
- package/dist/core/modules/health-check/core-health-check.service.js +40 -2
- package/dist/core/modules/health-check/core-health-check.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/migration-guides/11.46.10-to-11.46.11.md +57 -0
- package/migration-guides/11.46.9-to-11.46.10.md +61 -0
- package/package.json +4 -4
- package/src/core/modules/health-check/core-health-check.service.ts +74 -3
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Migration Guide: 11.46.10 → 11.46.11
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
| Category | Details |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **Breaking Changes** | None. Changed defaults: the MongoDB health check pings instead of reading `readyState`, and 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@11.46.11
|
|
16
|
+
pnpm run build
|
|
17
|
+
pnpm test
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Vendor mode**: run `/lt-dev:backend:update-nest-server-core` with `--target 11.46.11` as usual.
|
|
21
|
+
|
|
22
|
+
## 1. Health check: the MongoDB check pings, and waits up to 2000 ms
|
|
23
|
+
|
|
24
|
+
Terminus 11's `MongooseHealthIndicator` does not ping the database: it reports up when the Mongoose connection's
|
|
25
|
+
`readyState` is 1 and down otherwise. Mongoose sets `disconnected` as soon as the driver's topology briefly sees no
|
|
26
|
+
primary: a replica set without `ReplicaSetWithPrimary`, a single server turning `Unknown`. One lost heartbeat is
|
|
27
|
+
enough, while the database answers in milliseconds and the application's own queries simply wait for the driver's
|
|
28
|
+
server selection. On a cluster with managed MongoDB replica sets this caused far more than 95 % of all "database
|
|
29
|
+
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.mongoPingCheck()` / `pingMongoDb()`). 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 (message `timeout of <n>ms exceeded`), when the ping fails (the driver's message), or when the initial
|
|
34
|
+
connect has not finished yet (`Not connected to database`).
|
|
35
|
+
|
|
36
|
+
The timeout is now **2000 ms** (`DEFAULT_DATABASE_PING_TIMEOUT_MS`), unless
|
|
37
|
+
`healthCheck.configs.database.options.timeout` sets another value. Before, it was 300 ms without configured options
|
|
38
|
+
and 1000 ms with options but no `timeout`.
|
|
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' `readyState` check. To keep
|
|
42
|
+
the old timeout, set `healthCheck.configs.database.options.timeout: 300`.
|
|
43
|
+
|
|
44
|
+
## 2. Audit: minimatch 11.0.10, glob residual
|
|
45
|
+
|
|
46
|
+
Two advisories reached GitHub's global database on 2026-12-04, so `pnpm audit` fails without action:
|
|
47
|
+
|
|
48
|
+
- GHSA-3924-r96c-gp9w (low, minimatch 11.0.6 to 11.0.9): nest-server overrides it to 11.0.10. The override does not
|
|
49
|
+
reach your project; where `pnpm audit` reports it, add `'minimatch@>=11.0.0 <11.0.10': '11.0.10'` to `overrides` in
|
|
50
|
+
your `pnpm-workspace.yaml`.
|
|
51
|
+
- GHSA-c6wh-w8c3-cv3g (moderate, glob up to 14.0.5): fixed only in glob 14.0.6, while `@nestjs/cli` 11.0.24 (the newest
|
|
52
|
+
11.x) pins glob 13.0.6 exactly. Dev tooling only (the CLI's glob matches your own build patterns). nest-server
|
|
53
|
+
declares it like GHSA-qxr8-q827-836c: `ignoreGhsas` plus `unusableFixConsumers: { GHSA-c6wh-w8c3-cv3g: '@nestjs/cli@11.0.24 cannot use 14.0.6' }`. Do the same in your project if `pnpm audit` reports it.
|
|
54
|
+
|
|
55
|
+
## Module Documentation
|
|
56
|
+
|
|
57
|
+
- `src/core/modules/health-check/core-health-check.service.ts`: `mongoPingCheck()`, `pingMongoDb()`
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Migration Guide: 11.46.9 → 11.46.10
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
| Category | Details |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **Breaking Changes** | None |
|
|
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) |
|
|
11
|
+
| **Migration Effort** | Update the package. 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@11.46.10
|
|
17
|
+
pnpm run update # nest-server-starter based projects
|
|
18
|
+
pnpm audit
|
|
19
|
+
pnpm run build
|
|
20
|
+
pnpm test
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Vendor mode**: run `/lt-dev:backend:update-nest-server-core` with `--target 11.46.10` as usual, then raise the
|
|
24
|
+
project's own `undici` to 7.30.5 and `nodemailer` to 10.6.3: in vendor mode they are the project's dependencies.
|
|
25
|
+
|
|
26
|
+
## 1. Security: undici 7.30.5 and nodemailer 10.6.3
|
|
27
|
+
|
|
28
|
+
nodejs/undici published 13 advisories for the 7.x line on 2026-12-04; all of them cover the 7.30.2 that 11.46.9
|
|
29
|
+
ships, seven are high, and all are fixed in 7.30.4 (7.30.5 adds only a RISC-V build fix). Among them:
|
|
30
|
+
|
|
31
|
+
- **GHSA-fgj4-8x8v-fqhm** (high): the redirect interceptor verified a cross-origin redirect target's certificate
|
|
32
|
+
against the first host's name.
|
|
33
|
+
- **GHSA-h5rf-4xrf-76mc** (high): an assertion in the HTTP/1.1 response parser ends the process from `request()`
|
|
34
|
+
and `fetch()`.
|
|
35
|
+
|
|
36
|
+
The framework uses undici for `outboundFetch()`, the guarded fetch for URLs users enter (webhooks, export targets).
|
|
37
|
+
nodemailer 10.6.3 closes **GHSA-w5r8-mmxv-957g** (moderate: `attachDataUrls` leaks inline images into later
|
|
38
|
+
messages). Both are repository advisories that GitHub's global database does not list yet, so `pnpm audit` does not
|
|
39
|
+
report them. A project that overrides undici itself (an entry such as `'undici@>=7.0.0 <7.30.2': '7.30.2'`) raises
|
|
40
|
+
key and target to 7.30.5; otherwise the entry holds its other undici consumers on the vulnerable version.
|
|
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 11.46.10, undici advisories of 2026-12-04; remove after 2026-12-05 13:05 UTC
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Troubleshooting
|
|
52
|
+
|
|
53
|
+
| Symptom | Cause | Fix |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `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 |
|
|
56
|
+
| `pnpm why undici` lists 7.30.2 next to 7.30.5 | a project override still targets 7.30.2 (§1) | raise its key and target to 7.30.5 |
|
|
57
|
+
|
|
58
|
+
## Module Documentation
|
|
59
|
+
|
|
60
|
+
- [undici security advisories](https://github.com/nodejs/undici/security/advisories)
|
|
61
|
+
- [GHSA-w5r8-mmxv-957g](https://github.com/nodemailer/nodemailer/security/advisories/GHSA-w5r8-mmxv-957g)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "11.46.
|
|
3
|
+
"version": "11.46.11",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"mongoose": "9.12.3",
|
|
133
133
|
"multer": "2.5.0",
|
|
134
134
|
"node-mailjet": "6.0.11",
|
|
135
|
-
"nodemailer": "10.
|
|
135
|
+
"nodemailer": "10.6.3",
|
|
136
136
|
"object-path": "0.11.8",
|
|
137
137
|
"passport": "0.7.0",
|
|
138
138
|
"passport-jwt": "4.0.1",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"rxjs": "7.8.2",
|
|
142
142
|
"supertest": "7.3.1",
|
|
143
143
|
"ts-morph": "28.0.0",
|
|
144
|
-
"undici": "7.30.
|
|
144
|
+
"undici": "7.30.5",
|
|
145
145
|
"ws": "8.23.0",
|
|
146
146
|
"yuml-diagram": "1.2.0"
|
|
147
147
|
},
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
"oxfmt": "0.73.0",
|
|
221
221
|
"oxlint": "1.88.0",
|
|
222
222
|
"rimraf": "6.1.4",
|
|
223
|
-
"smtp-server": "3.21.
|
|
223
|
+
"smtp-server": "3.21.9",
|
|
224
224
|
"ts-node": "10.9.2",
|
|
225
225
|
"tsconfig-paths": "4.2.0",
|
|
226
226
|
"tsx": "4.23.15",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Injectable, Optional } from '@nestjs/common';
|
|
2
|
+
import { InjectConnection } from '@nestjs/mongoose';
|
|
2
3
|
import {
|
|
3
4
|
DiskHealthIndicator,
|
|
4
5
|
HealthCheckResult,
|
|
5
6
|
HealthCheckService,
|
|
7
|
+
HealthIndicatorService,
|
|
6
8
|
MemoryHealthIndicator,
|
|
7
9
|
MongooseHealthIndicator,
|
|
8
10
|
} from '@nestjs/terminus';
|
|
@@ -12,6 +14,20 @@ import type { DiskHealthIndicatorOptions } from '@nestjs/terminus/dist/health-in
|
|
|
12
14
|
import { getBuildInfo } from '../../common/helpers/meta.helper';
|
|
13
15
|
import { ConfigService } from '../../common/services/config.service';
|
|
14
16
|
|
|
17
|
+
/**
|
|
18
|
+
* How long the MongoDB ping may take before the health check reports the database as down, unless
|
|
19
|
+
* `healthCheck.configs.database.options.timeout` sets another value (11.46.11; before: 300 ms without options, 1000 ms
|
|
20
|
+
* with options but no `timeout`). The ping waits for the driver's server selection (see
|
|
21
|
+
* {@link CoreHealthCheckService.pingMongoDb}), which rides out a replica set that briefly sees no primary; 2 s still
|
|
22
|
+
* fails a database that does not answer and stays below the readiness probe timeout of the lt charts (3 s).
|
|
23
|
+
*/
|
|
24
|
+
export const DEFAULT_DATABASE_PING_TIMEOUT_MS = 2000;
|
|
25
|
+
|
|
26
|
+
/** The part of a Mongoose connection the health check's MongoDB ping uses */
|
|
27
|
+
export interface IHealthCheckMongoConnection {
|
|
28
|
+
db?: { command(command: Record<string, unknown>): Promise<unknown> } | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
15
31
|
/**
|
|
16
32
|
* Core health check service
|
|
17
33
|
* Inspired by https://mobileappcircular.com/marketplace-backend-creating-a-health-check-endpoint-in-nestjs-app-using-terminus-25727e96c7d2
|
|
@@ -26,13 +42,21 @@ export class CoreHealthCheckService {
|
|
|
26
42
|
protected memory: MemoryHealthIndicator,
|
|
27
43
|
) {}
|
|
28
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The application's Mongoose connection for the MongoDB ping (11.46.11). Injected as a property, so a project
|
|
47
|
+
* subclass with its own constructor receives it too.
|
|
48
|
+
*/
|
|
49
|
+
@Optional()
|
|
50
|
+
@InjectConnection()
|
|
51
|
+
protected mongoConnection?: IHealthCheckMongoConnection | null;
|
|
52
|
+
|
|
29
53
|
healthCheck(): Promise<HealthCheckResult> {
|
|
30
54
|
const healthIndicatorFunctions = [];
|
|
31
55
|
if (this.config.get<boolean>('healthCheck.configs.database.enabled')) {
|
|
32
56
|
healthIndicatorFunctions.push(() =>
|
|
33
|
-
this.
|
|
57
|
+
this.mongoPingCheck(
|
|
34
58
|
this.config.get<string>('healthCheck.configs.database.key') ?? 'database',
|
|
35
|
-
this.config.get<MongoosePingCheckSettings>('healthCheck.configs.database.options') ?? {
|
|
59
|
+
this.config.get<MongoosePingCheckSettings>('healthCheck.configs.database.options') ?? {},
|
|
36
60
|
),
|
|
37
61
|
);
|
|
38
62
|
}
|
|
@@ -79,4 +103,51 @@ export class CoreHealthCheckService {
|
|
|
79
103
|
|
|
80
104
|
return this.health.check(healthIndicatorFunctions);
|
|
81
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The MongoDB indicator (11.46.11): up when the database answers a real `ping` within the timeout.
|
|
109
|
+
*
|
|
110
|
+
* Replaces Terminus' `MongooseHealthIndicator.pingCheck()`, which in Terminus 11 does not ping at all: it reports
|
|
111
|
+
* up when the connection's `readyState` is 1 and down otherwise. Mongoose sets `disconnected` as soon as the
|
|
112
|
+
* driver's topology briefly sees no primary (a replica set without `ReplicaSetWithPrimary`, a single server turning
|
|
113
|
+
* `Unknown`): one lost heartbeat is enough, while the database answers in milliseconds and the application's own
|
|
114
|
+
* queries just wait for the driver's server selection. On a cluster with managed MongoDB replica sets that produced
|
|
115
|
+
* far more than 95 % of all "database down" alarms. Falls back to Terminus' check when no connection is available.
|
|
116
|
+
*/
|
|
117
|
+
protected async mongoPingCheck(key: string, options: MongoosePingCheckSettings) {
|
|
118
|
+
const connection: IHealthCheckMongoConnection | null | undefined = options.connection ?? this.mongoConnection;
|
|
119
|
+
if (!connection) {
|
|
120
|
+
return this.db.pingCheck(key, { timeout: DEFAULT_DATABASE_PING_TIMEOUT_MS, ...options });
|
|
121
|
+
}
|
|
122
|
+
const timeout = options.timeout || DEFAULT_DATABASE_PING_TIMEOUT_MS;
|
|
123
|
+
const check = new HealthIndicatorService().check(key);
|
|
124
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
125
|
+
try {
|
|
126
|
+
await Promise.race([
|
|
127
|
+
this.pingMongoDb(connection),
|
|
128
|
+
new Promise<never>((_, reject) => {
|
|
129
|
+
timer = setTimeout(() => reject(new Error(`timeout of ${timeout}ms exceeded`)), timeout);
|
|
130
|
+
}),
|
|
131
|
+
]);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
return check.down({ message: (error as Error)?.message ?? String(error) });
|
|
134
|
+
} finally {
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
}
|
|
137
|
+
return check.up();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Pings the MongoDB the application uses: a real `ping` command that waits for the driver's server selection like
|
|
142
|
+
* any query — deliberately without a `readyState` check (see {@link mongoPingCheck}).
|
|
143
|
+
*
|
|
144
|
+
* @param connection The Mongoose connection (`healthCheck.configs.database.options.connection` or the injected one)
|
|
145
|
+
*/
|
|
146
|
+
protected async pingMongoDb(connection: IHealthCheckMongoConnection): Promise<void> {
|
|
147
|
+
if (!connection.db) {
|
|
148
|
+
// Not connected yet (the initial connect is still running) or never connected
|
|
149
|
+
throw new Error('Not connected to database');
|
|
150
|
+
}
|
|
151
|
+
await connection.db.command({ ping: 1 });
|
|
152
|
+
}
|
|
82
153
|
}
|