@bymax-one/nest-logger 1.4.19 → 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 +14 -1
- package/README.md +3 -3
- package/dist/server/index.cjs +16 -2
- package/dist/server/index.mjs +16 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,18 @@ heading here.
|
|
|
12
12
|
|
|
13
13
|
## [Unreleased]
|
|
14
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
|
+
|
|
15
27
|
## [1.4.19] - 2026-11-14
|
|
16
28
|
|
|
17
29
|
### Changed
|
|
@@ -2903,7 +2915,8 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
|
|
|
2903
2915
|
- Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
|
|
2904
2916
|
`release.yml`, Dependabot, and issue templates
|
|
2905
2917
|
|
|
2906
|
-
[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
|
|
2907
2920
|
[1.4.19]: https://github.com/bymaxone/nest-logger/compare/v1.4.18...v1.4.19
|
|
2908
2921
|
[1.4.18]: https://github.com/bymaxone/nest-logger/compare/v1.4.17...v1.4.18
|
|
2909
2922
|
[1.4.17]: https://github.com/bymaxone/nest-logger/compare/v1.4.16...v1.4.17
|
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
|
| --------------------------- | -------- | ---------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -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
|
|
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.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