@bymax-one/nest-logger 1.4.18 → 1.4.20
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/CHANGELOG.md +28 -3
- package/README.md +5 -5
- package/dist/server/index.cjs +16 -2
- package/dist/server/index.d.cts +4 -3
- package/dist/server/index.d.ts +4 -3
- package/dist/server/index.mjs +16 -2
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@bymax-one/nest-logger` are documented here.
|
|
4
4
|
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
|
-
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
|
+
|
|
7
|
+
Versioning is **not** strict [SemVer](https://semver.org/spec/v2.0.0.html) while this API is pre-stable: breaking changes ship in minor and patch releases by explicit `@bymax-one` policy, so a version number carries no compatibility information. The **Apply to a derived backend** note, on the entries that carry one, is the compatibility contract — read it, not the number.
|
|
7
8
|
|
|
8
9
|
The `release.yml` workflow extracts the section matching the pushed `vX.Y.Z` tag
|
|
9
10
|
as the GitHub Release body, so each released version needs a matching `## [X.Y.Z]`
|
|
@@ -11,6 +12,28 @@ heading here.
|
|
|
11
12
|
|
|
12
13
|
## [Unreleased]
|
|
13
14
|
|
|
15
|
+
## [1.4.20] - 2026-11-17
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **A `SIGTERM` no longer discards what a slow stdout reader had not yet taken.** With
|
|
20
|
+
`app.enableShutdownHooks()`, Nest closes the application and then raises the signal again, which
|
|
21
|
+
ends the process. The shutdown drain waited only for the module's own queue, so the bytes
|
|
22
|
+
`process.stdout` still held were lost: on Linux with node 24, a reader slower than the writer
|
|
23
|
+
received 739 of 30000 lines. The drain now also waits while the default stdout destination's
|
|
24
|
+
`process.stdout` holds bytes, inside `shutdown.drainTimeoutMs`, and names the size in the existing
|
|
25
|
+
"entries still queued" line when the time runs out. Nothing for a backend to do.
|
|
26
|
+
|
|
27
|
+
## [1.4.19] - 2026-11-14
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- The `REDACT_COMMON_FIELDS` JSDoc and the README's notes on `DEFAULT_REDACT_PATHS` said a removal
|
|
32
|
+
requires a major version, which this project's versioning does not use; they now say that a name
|
|
33
|
+
may be added in any release and none is removed without a recorded decision and an Apply note in
|
|
34
|
+
this changelog that names the field. The lists stay append-only. Documentation only: the built
|
|
35
|
+
JavaScript is unchanged and there is nothing for a backend to do.
|
|
36
|
+
|
|
14
37
|
## [1.4.18] - 2026-11-14
|
|
15
38
|
|
|
16
39
|
### Changed (Security)
|
|
@@ -2892,7 +2915,9 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
|
|
|
2892
2915
|
- Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
|
|
2893
2916
|
`release.yml`, Dependabot, and issue templates
|
|
2894
2917
|
|
|
2895
|
-
[Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.
|
|
2918
|
+
[Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.20...HEAD
|
|
2919
|
+
[1.4.20]: https://github.com/bymaxone/nest-logger/compare/v1.4.19...v1.4.20
|
|
2920
|
+
[1.4.19]: https://github.com/bymaxone/nest-logger/compare/v1.4.18...v1.4.19
|
|
2896
2921
|
[1.4.18]: https://github.com/bymaxone/nest-logger/compare/v1.4.17...v1.4.18
|
|
2897
2922
|
[1.4.17]: https://github.com/bymaxone/nest-logger/compare/v1.4.16...v1.4.17
|
|
2898
2923
|
[1.4.16]: https://github.com/bymaxone/nest-logger/compare/v1.4.15...v1.4.16
|
package/README.md
CHANGED
|
@@ -301,7 +301,7 @@ Full options reference for `BymaxLoggerModule.forRoot(options)`:
|
|
|
301
301
|
|
|
302
302
|
### `shutdown` options
|
|
303
303
|
|
|
304
|
-
Shutdown first drains the queue each destination holds, then calls each destination's `onShutdown` in reverse registration order. One budget covers the drain and every `onShutdown`, so the worst case is `shutdown.timeoutMs`, whatever the number of destinations. A destination reached after the budget is spent is named in one stderr line and its `onShutdown` is not called. Keep the budget below the grace period your platform gives the process, together with whatever else shuts down in it. Entries logged after the drain ended, by a host that logs in its own shutdown hook, are not waited for. Keep `shutdown.drainTimeoutMs` below `shutdown.timeoutMs`: a drain equal to the total, and a short total whose default drain is capped to it, leave no time for `onShutdown` when a queue never empties, and every `onShutdown` is then skipped and named.
|
|
304
|
+
Shutdown first drains the queue each destination holds, and for the default stdout destination also what `process.stdout` has not yet handed to its reader, then calls each destination's `onShutdown` in reverse registration order. One budget covers the drain and every `onShutdown`, so the worst case is `shutdown.timeoutMs`, whatever the number of destinations. A destination reached after the budget is spent is named in one stderr line and its `onShutdown` is not called. Keep the budget below the grace period your platform gives the process, together with whatever else shuts down in it. Entries logged after the drain ended, by a host that logs in its own shutdown hook, are not waited for. Keep `shutdown.drainTimeoutMs` below `shutdown.timeoutMs`: a drain equal to the total, and a short total whose default drain is capped to it, leave no time for `onShutdown` when a queue never empties, and every `onShutdown` is then skipped and named.
|
|
305
305
|
|
|
306
306
|
| Option | Type | Default | Description |
|
|
307
307
|
| ------------------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -316,7 +316,7 @@ The count is the module's own queue in front of the destination plus what the de
|
|
|
316
316
|
|
|
317
317
|
**A stalled stdout consumer now loses entries past `destinationQueue.maxBytes` instead of growing the process; set `0` to restore the old behaviour.** Measured on 400000 lines to a pipe nobody reads: the process grew by 289865728 bytes with no bound and by 69681152 bytes with a 4 MiB bound.
|
|
318
318
|
|
|
319
|
-
An entry still queued when the process ends is lost. `process.exit()` does not wait for a queue: measured on a pipe, 568 of 200000 lines were delivered after `process.exit()`, and `await app.close()` before the exit delivers them all, within the `shutdown` budget above.
|
|
319
|
+
An entry still queued when the process ends is lost. `process.exit()` does not wait for a queue: measured on a pipe, 568 of 200000 lines were delivered after `process.exit()`, and `await app.close()` before the exit delivers them all, within the `shutdown` budget above. The same holds for a `SIGTERM` with `app.enableShutdownHooks()`: Nest raises the signal again when the hooks return, which ends the process, so the drain is the last chance for what stdout holds. Measured on Linux with node 24, a reader slower than the writer received all 30002 lines with the wait, and 739 of 30000 without it. A reader that never reads holds the drain to `shutdown.drainTimeoutMs`, and one stderr line names the bytes stdout still held. After `await app.close()` without a signal, a process whose stdout reader has stalled stays alive until the pipe drains; the platform ends it at its grace period (`SIGKILL`), and what stdout held then is lost.
|
|
320
320
|
|
|
321
321
|
| Option | Type | Default | Description |
|
|
322
322
|
| --------------------------- | -------- | ---------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -858,7 +858,7 @@ A `LOGGER_BOOTSTRAP_WARNING` is emitted on startup so security reviews can audit
|
|
|
858
858
|
|
|
859
859
|
### An append-only default list
|
|
860
860
|
|
|
861
|
-
`DEFAULT_REDACT_PATHS` is append-only by contract: a path may be added in
|
|
861
|
+
`DEFAULT_REDACT_PATHS` is append-only by contract: a path may be added in any release, and none is removed without a recorded decision and an Apply note in `CHANGELOG.md` that names the field. A field that silently stopped being redacted is a leak nobody would notice.
|
|
862
862
|
|
|
863
863
|
### Validated trace identifiers
|
|
864
864
|
|
|
@@ -870,7 +870,7 @@ Every `write()` runs inside a try/catch. A destination that throws or rejects pr
|
|
|
870
870
|
|
|
871
871
|
### What redaction covers, and what it cannot
|
|
872
872
|
|
|
873
|
-
The walk is bounded: a container nested more than 100 levels deep is written as `[REDACTION_DEPTH_EXCEEDED]`, and a call that visits more than 200000 containers writes `[REDACTION_BUDGET_EXCEEDED]` in place of each further one. A stack or message is written at most 16384 characters long and ends with `…[truncated]` when cut. A string under a metadata key is the caller's own data and is written as given: `maxEntrySizeBytes` bounds what a serializer returns, not a metadata string.
|
|
873
|
+
The walk is bounded: a container nested more than 100 levels deep is written as `[REDACTION_DEPTH_EXCEEDED]`, and a call that visits more than 200000 containers writes `[REDACTION_BUDGET_EXCEEDED]` in place of each further one. The budget bounds the work, not the cost: measured on built `dist` under node 24 (an Apple-silicon laptop), an array of 250000 small objects took 119 ms of the event loop per entry and wrote about 4 MB, most of it the marker repeated for each container past the budget, and 50000 keys in one object took 23 ms. Do not log a collection of unbounded size; log its length and a sample. A stack or message is written at most 16384 characters long and ends with `…[truncated]` when cut. A string under a metadata key is the caller's own data and is written as given: `maxEntrySizeBytes` bounds what a serializer returns, not a metadata string.
|
|
874
874
|
|
|
875
875
|
Redaction matches **field names**, not values. A secret under a covered name is censored at any depth (under the legacy `'paths'` strategy the four-level ceiling applies instead), but the same secret **embedded inside a string** under an uncovered name travels intact:
|
|
876
876
|
|
|
@@ -928,7 +928,7 @@ Every serializer, the default `err` one and any you supply, is wrapped so a fiel
|
|
|
928
928
|
| PCI DSS | `cardNumber`, `cardCvv`, `cvv`, `cvc`, `cardExpiry` |
|
|
929
929
|
| LGPD documents | `cpf`, `cnpj`, `rg`, plus `email` as a conservative default |
|
|
930
930
|
| HTTP headers | `authorization`, `cookie`, `x-api-key`, `x-auth-token`, `set-cookie` |
|
|
931
|
-
| Redact list | `DEFAULT_REDACT_PATHS` is append-only; removal
|
|
931
|
+
| Redact list | `DEFAULT_REDACT_PATHS` is append-only; a removal needs a recorded decision and an Apply note |
|
|
932
932
|
| Trace injection | `isValidTraceId` / `isValidSpanId` validate every identifier before it is written |
|
|
933
933
|
| URL cardinality | UUIDs, ULIDs, nanoids and numeric IDs become `:id`; the query string is stripped |
|
|
934
934
|
| Destination failure | Every `write()` is wrapped; a failure goes to `stderr` and is swallowed |
|
package/dist/server/index.cjs
CHANGED
|
@@ -3561,6 +3561,20 @@ var DestinationRegistry = class {
|
|
|
3561
3561
|
}
|
|
3562
3562
|
}
|
|
3563
3563
|
}
|
|
3564
|
+
/**
|
|
3565
|
+
* What a destination still holds for the drain to wait on: its module queue, and for the default
|
|
3566
|
+
* stdout destination also what `process.stdout` has not yet handed to its reader. Nest raises the
|
|
3567
|
+
* signal again once the shutdown hooks return, which ends the process, so what stdout still held
|
|
3568
|
+
* then was lost. Another destination's own buffer is not counted: it may flush only in
|
|
3569
|
+
* `onShutdown`, which runs after the drain.
|
|
3570
|
+
*
|
|
3571
|
+
* @param destination - An active destination.
|
|
3572
|
+
* @returns The bytes the drain waits on for it.
|
|
3573
|
+
*/
|
|
3574
|
+
heldSize(destination) {
|
|
3575
|
+
const queued = this.health.queuedSize(destination);
|
|
3576
|
+
return destination instanceof exports.DefaultStdoutDestination ? queued + process.stdout.writableLength : queued;
|
|
3577
|
+
}
|
|
3564
3578
|
/**
|
|
3565
3579
|
* Wait until no active destination holds a queued entry, or the drain deadline passes.
|
|
3566
3580
|
*
|
|
@@ -3575,12 +3589,12 @@ var DestinationRegistry = class {
|
|
|
3575
3589
|
*/
|
|
3576
3590
|
async drain(drainDeadline) {
|
|
3577
3591
|
for (; ; ) {
|
|
3578
|
-
const queued = this.active.filter((destination) => this.
|
|
3592
|
+
const queued = this.active.filter((destination) => this.heldSize(destination) > 0);
|
|
3579
3593
|
if (queued.length === 0) return;
|
|
3580
3594
|
const remaining = drainDeadline - performance.now();
|
|
3581
3595
|
if (remaining <= 0) {
|
|
3582
3596
|
const named = queued.map(
|
|
3583
|
-
(destination) => `"${toSingleLineMessage(safeDestinationName(destination))}" (${String(this.
|
|
3597
|
+
(destination) => `"${toSingleLineMessage(safeDestinationName(destination))}" (${String(this.heldSize(destination))})`
|
|
3584
3598
|
);
|
|
3585
3599
|
writeStderrSafely(
|
|
3586
3600
|
`[DestinationRegistry] Shutdown drain ended with entries still queued, by size: ${named.join(", ")}
|
package/dist/server/index.d.cts
CHANGED
|
@@ -2022,9 +2022,10 @@ declare const LOG_CONTEXT_TOKEN: unique symbol;
|
|
|
2022
2022
|
* Under the legacy `'paths'` strategy the same names are expanded to depths 1–4
|
|
2023
2023
|
* by {@link depth} to build {@link DEFAULT_REDACT_PATHS}.
|
|
2024
2024
|
*
|
|
2025
|
-
* Append-only: a name may be added in
|
|
2026
|
-
*
|
|
2027
|
-
*
|
|
2025
|
+
* Append-only: a name may be added in any release, and none is removed without
|
|
2026
|
+
* a recorded decision and an Apply note in `CHANGELOG.md` that names the field,
|
|
2027
|
+
* because a field that silently stopped being redacted is a leak no consumer
|
|
2028
|
+
* would notice.
|
|
2028
2029
|
*/
|
|
2029
2030
|
declare const REDACT_COMMON_FIELDS: readonly string[];
|
|
2030
2031
|
/**
|
package/dist/server/index.d.ts
CHANGED
|
@@ -2022,9 +2022,10 @@ declare const LOG_CONTEXT_TOKEN: unique symbol;
|
|
|
2022
2022
|
* Under the legacy `'paths'` strategy the same names are expanded to depths 1–4
|
|
2023
2023
|
* by {@link depth} to build {@link DEFAULT_REDACT_PATHS}.
|
|
2024
2024
|
*
|
|
2025
|
-
* Append-only: a name may be added in
|
|
2026
|
-
*
|
|
2027
|
-
*
|
|
2025
|
+
* Append-only: a name may be added in any release, and none is removed without
|
|
2026
|
+
* a recorded decision and an Apply note in `CHANGELOG.md` that names the field,
|
|
2027
|
+
* because a field that silently stopped being redacted is a leak no consumer
|
|
2028
|
+
* would notice.
|
|
2028
2029
|
*/
|
|
2029
2030
|
declare const REDACT_COMMON_FIELDS: readonly string[];
|
|
2030
2031
|
/**
|
package/dist/server/index.mjs
CHANGED
|
@@ -3558,6 +3558,20 @@ var DestinationRegistry = class {
|
|
|
3558
3558
|
}
|
|
3559
3559
|
}
|
|
3560
3560
|
}
|
|
3561
|
+
/**
|
|
3562
|
+
* What a destination still holds for the drain to wait on: its module queue, and for the default
|
|
3563
|
+
* stdout destination also what `process.stdout` has not yet handed to its reader. Nest raises the
|
|
3564
|
+
* signal again once the shutdown hooks return, which ends the process, so what stdout still held
|
|
3565
|
+
* then was lost. Another destination's own buffer is not counted: it may flush only in
|
|
3566
|
+
* `onShutdown`, which runs after the drain.
|
|
3567
|
+
*
|
|
3568
|
+
* @param destination - An active destination.
|
|
3569
|
+
* @returns The bytes the drain waits on for it.
|
|
3570
|
+
*/
|
|
3571
|
+
heldSize(destination) {
|
|
3572
|
+
const queued = this.health.queuedSize(destination);
|
|
3573
|
+
return destination instanceof DefaultStdoutDestination ? queued + process.stdout.writableLength : queued;
|
|
3574
|
+
}
|
|
3561
3575
|
/**
|
|
3562
3576
|
* Wait until no active destination holds a queued entry, or the drain deadline passes.
|
|
3563
3577
|
*
|
|
@@ -3572,12 +3586,12 @@ var DestinationRegistry = class {
|
|
|
3572
3586
|
*/
|
|
3573
3587
|
async drain(drainDeadline) {
|
|
3574
3588
|
for (; ; ) {
|
|
3575
|
-
const queued = this.active.filter((destination) => this.
|
|
3589
|
+
const queued = this.active.filter((destination) => this.heldSize(destination) > 0);
|
|
3576
3590
|
if (queued.length === 0) return;
|
|
3577
3591
|
const remaining = drainDeadline - performance.now();
|
|
3578
3592
|
if (remaining <= 0) {
|
|
3579
3593
|
const named = queued.map(
|
|
3580
|
-
(destination) => `"${toSingleLineMessage(safeDestinationName(destination))}" (${String(this.
|
|
3594
|
+
(destination) => `"${toSingleLineMessage(safeDestinationName(destination))}" (${String(this.heldSize(destination))})`
|
|
3581
3595
|
);
|
|
3582
3596
|
writeStderrSafely(
|
|
3583
3597
|
`[DestinationRegistry] Shutdown drain ended with entries still queued, by size: ${named.join(", ")}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-logger",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.20",
|
|
4
4
|
"description": "Structured JSON logging for NestJS based on Pino 10, with optional OpenTelemetry correlation.",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,9 +62,11 @@
|
|
|
62
62
|
"check:mutants": "node scripts/check-mutation-directives.mjs",
|
|
63
63
|
"check:published": "node scripts/check-published-surface.mjs",
|
|
64
64
|
"check:file-length": "node scripts/check-file-length.mjs",
|
|
65
|
+
"check:spec-headers": "node scripts/check-spec-headers.mjs",
|
|
66
|
+
"check:suppressions": "node scripts/check-suppressions-baseline.mjs",
|
|
65
67
|
"clean": "rm -rf dist coverage",
|
|
66
68
|
"check:socket-gate": "node scripts/check-socket-gate.mjs",
|
|
67
|
-
"lint": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' && pnpm check:socket-gate",
|
|
69
|
+
"lint": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' && pnpm check:socket-gate && pnpm check:spec-headers && node --test scripts/check-spec-headers.test.mjs && node --test scripts/check-suppressions-baseline.test.mjs",
|
|
68
70
|
"lint:fix": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' --fix",
|
|
69
71
|
"mutation": "stryker run",
|
|
70
72
|
"mutation:full": "node -e \"require('node:fs').rmSync('reports/stryker-incremental.json',{force:true,recursive:true})\" && stryker run",
|