@bymax-one/nest-logger 1.4.29 → 1.4.31

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 CHANGED
@@ -12,6 +12,112 @@ heading here.
12
12
 
13
13
  ## [Unreleased]
14
14
 
15
+ ## [1.4.31] - 2026-11-25
16
+
17
+ ### Changed
18
+
19
+ Both were measured against 1.4.30. For the input a real caller produces, the output is the same.
20
+
21
+ - **Hiding a message longer than the stack it is searched in costs more time.** The message is now cut to one character more than the stack before it is searched, so the table the search builds is bounded by the stack. Measured per call with a message of 10,000,000 characters: 0.009 ms to 1.41 ms for a concatenated message, 0.001 ms to 0.225 ms for a repeated pattern.
22
+ - **`PinoUnexpectedErrorSink` reads `error.getResponse` once.** It was read once to check its type and again to call it. An accessor that answers differently on the second read now gets the fields of its first answer.
23
+
24
+ ### Documentation
25
+
26
+ - **A body parser mounted after `app.init()` does not produce a parser entry; the README said it kept the parser's message.** Measured through `NestFactory` and real HTTP, with a malformed JSON body to a route: with Nest's default parser the answer is `400` and `HTTP_EXCEPTION_HANDLED` carries `bodyParserType: 'entity.parse.failed'`; with `express.json()` mounted after `app.init()`, and with no parser at all, the route runs with no parsed body (`201`) and no `HTTP_EXCEPTION_HANDLED` entry is written. Measured with the packed library in a scratch package, `@nestjs/platform-fastify` 11.2.9 and Fastify 5.12.8: the same malformed body answers `400` and `HTTP_EXCEPTION_HANDLED` carries Fastify's own message with no `bodyParserType`, and the response the filter writes fails with `res.status(...).json is not a function`. The Fastify adapter stays unsupported, so this is a documented limit (issue #211), not a gap to close. No code change.
27
+ - **`options.level` outside the Pino levels is refused.** Measured: `'verbose'`, `'silent'`, `'FATAL'` and the number `30` each make `forRoot` throw, and `'silent'` makes `forRootAsync` throw at bootstrap; the README did not say what happens to a value outside the levels. No code change.
28
+
29
+ ## [1.4.30] - 2026-11-24
30
+
31
+ ### Breaking
32
+
33
+ - **`LoggerHealthIndicator.check()` answers a frozen verdict.** The result and its `details` are
34
+ frozen, so code that adds or changes a field on the result that `check()` resolves to throws a `TypeError` in strict
35
+ mode (and drops the write silently in sloppy mode). Migration: copy before you mutate, for example
36
+ `const verdict = { ...result, details: { ...result.details } }`, and change the copy.
37
+ The result also has no prototype, so `result.hasOwnProperty(...)` and a template string of it throw
38
+ a `TypeError`, and `assert.deepStrictEqual` against a plain object fails; the same spread copy is a
39
+ plain object, so compare or call methods on the copy. `details` is an ordinary frozen object.
40
+
41
+ ### Fixed
42
+
43
+ - **A replaced `Promise.resolve`, a replaced `Promise.prototype.constructor` and a `then` planted on a
44
+ prototype root no longer decide what the logger awaits, in the cases measured here.** Measured: with `Promise.resolve` replaced after
45
+ the import, the health indicator answered `up` for a delivery with no healthy sink, `withTimeout` settled a
46
+ hook that had rejected, a failed destination write was not recorded for readiness, and a late rejection of a
47
+ tenant resolver reached the process. The sites no longer read a static of `Promise`: a promise the
48
+ library builds comes from the intrinsic constructor (taken from an async function, so a `globalThis.Promise`
49
+ set before the load is not it), a wait is an `await`, and the outcome of a wait is a box with no prototype.
50
+ Before each `await` that feeds a verdict the baseline is asserted, with no call of the host between the
51
+ check and the wait: `Promise.prototype.constructor` is the intrinsic one and no `then` sits on
52
+ `Object.prototype`, `Array.prototype` or `Function.prototype`. A failed assertion refuses the verdict: a
53
+ hook is reported as failed, a write is recorded as failed and reported on stderr. A `then` of
54
+ `Promise.prototype` that a runtime wraps (a context manager) is allowed. `withTimeout` now resolves with
55
+ nothing. A source scan fails for a new read of a static, a
56
+ `new Promise`, `.then(`, `.catch(` or `.finally(` in `src`.
57
+ A native promise a hook or a destination returns is waited for through the intrinsic constructor, for the
58
+ length of one synchronous call, and is refused when it already carries its own `constructor` or `then`
59
+ or cannot take that slot.
60
+ Known limits: a frozen, sealed or non-extensible native promise cannot take a handler under a replaced
61
+ `Promise.prototype.constructor` whose species throws, so a rejection of it can reach the process (a
62
+ waited-for promise of that shape is refused instead); while a rejection is absorbed, the temporary
63
+ `constructor` of the promise can stay if a species getter makes it non-configurable inside that window;
64
+ code running concurrently that plants a `then` and erases it again between the check and the
65
+ work's own settlement cannot be seen afterwards, and a dependency that reads a static inside itself is code
66
+ aimed at that dependency, not at the logger. Code that replaces the `constructor` of `Promise.prototype`
67
+ before this package is loaded is not detected either: the intrinsic is read from that slot at load, so
68
+ the baseline is the replacement. These guards are best-effort hardening, not a security
69
+ boundary: code running inside the host process is trusted (SECURITY.md, "Threat model: same-process
70
+ code"). A descriptor read by these guards, and by the `toJSON` lookup outside `errorOwnFields: 'safe'` and the options filter, is read for
71
+ its own `get` and `value` only, so a field planted on `Object.prototype` is not taken for one.
72
+ - **A key planted on `Object.prototype` is no option.** The options were read by property access through
73
+ the prototype chain, so a `shouldDisableDefaultRedact: true` planted on `Object.prototype` (by a
74
+ dependency with a prototype-pollution flaw) turned the default redact paths off, and `redactCensor`,
75
+ `level` and the rest were read the same way. A value that only a root prototype (one with no prototype of its own, such as the
76
+ `Object.prototype` of any realm) holds is now skipped, the options and their groups are kept in objects
77
+ with no prototype, and so is the `service` metadata; a key the object has itself, and a getter a class
78
+ prototype defines, still count. A built-in that the redaction reads and a program replaces after the import drops the record and redacts a URL path whole: each one in the table (`GUARDED_BUILTINS` in `src/server/utils/captured-builtins.util.ts`, held by a spec to the calls of five files: `fold-key`, `normalize-url`, `matches-exclude-path`, `sanitize-error` and `pino-factory`) is compared with the one the module loaded with. What `redact-by-name`, the error-text exemption, `redact-error-parts`, the mixin merge, the truncation and `bounded-text` call is outside the table. A value whose prototype chain does not end within the bound in `resolve-to-json.util.ts` is written as the censor. What was replaced before the import is outside this. A `get` or `set` installed with `Object.defineProperty` (an accessor, which plain assignment cannot make) is outside what this guards. A `get` or a `set` planted there no longer reaches a descriptor the logger
79
+ defines, and options read through a Proxy under a planted accessor of the same name are refused. Pino got the same: it is handed an own value for each option it reads
80
+ and the library does not set, and so is each entry handed to its multistream, so a planted one is not
81
+ seen. Out of scope, because Node and Pino read them off objects this library does
82
+ not build: keys such as `message` and `toJSON`, which the emit and `JSON.stringify` read.
83
+ A key planted by plain assignment, so that it is enumerable, under `level`, `msgPrefix` or `levelVal`
84
+ makes Pino throw while the logger is built, and under `levels` at the first Nest-style log call, since
85
+ Pino assigns to its instance every key a `for...in` over its level table finds, inherited ones included;
86
+ no option can shadow that.
87
+ - **A name spelled with symbol glyphs is read as the name.** The negative circled letters
88
+ (`U+1F150`..), the negative squared letters (`U+1F170`..) and the regional indicators (`U+1F1E6`..)
89
+ have no compatibility form, so the fold dropped them as punctuation and `🆃🅾🅺🅴🅽` folded to nothing
90
+ and kept its value in clear, at every depth, in a flat header array and as a property of an `Error`.
91
+ Each is now read as the Latin letter its Unicode name ends in. The table is generated from the
92
+ Unicode Character Database names (`scripts/generate-glyph-letters.mjs`, with a test that holds the
93
+ generated file to its input).
94
+ - **A key that only spells `stack` is written as a stack at the root of an entry too.** The message the
95
+ options hide is hidden in the header of a `Stack`, `STACK` or zero-width spelling of the stack of an
96
+ object message, as it is below the root, and in the same kind of own property of an `Error`.
97
+ - **The stack of a plain object is bounded whatever its message.** A message longer than the text limit
98
+ made the part of the stack that is searched as long as the message, and buffering one span for every
99
+ place a dense run matched cost memory out of proportion to the stack. A message longer than the text limit is no longer searched for:
100
+ the stack is written as the censor, as it is for more than eight messages, and a run of overlapping
101
+ matches is one span again.
102
+ - **A symbol that is not ASCII stands for a letter in a key.** A copyright sign, a sound recording sign,
103
+ a multiplication sign or any other symbol of the categories `So`, `Sm` and `Sk` was dropped as
104
+ punctuation, so `℗assword`, `©ookie` and `tok℮n` kept their value in clear. Each now stands for nothing,
105
+ one or two characters of a name, where a value is hidden, which hides the value of those keys and of a
106
+ short key that holds such a symbol (over-hiding is the price, as for a letter of another script). Dashes
107
+ and spaces are still dropped, and the keys the entry owns are still compared exactly.
108
+ - **An own enumerable `stack` of an `Error` is written as a stack.** The message the options hide is hidden
109
+ in it like in any key that spells `stack`.
110
+ - **The stack keys at the root of an entry are capped like those below it,** and the positional stack of
111
+ `error(object, stack)` has the message hidden: it was attached after the message was hidden.
112
+
113
+ ### Changed
114
+
115
+ - **A `redactPaths` entry is at most 256 characters.** A longer one is refused at startup by the name
116
+ of the option and its index (`options.redactPaths[i] must be at most 256 characters`), without echoing
117
+ it, where earlier releases accepted it and the application started. This holds for every strategy.
118
+ **Apply to a consumer:** an
119
+ entry over 256 characters now refuses boot; shorten it.
120
+
15
121
  ## [1.4.29] - 2026-11-21
16
122
 
17
123
  ### Fixed
@@ -3469,7 +3575,9 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
3469
3575
  - Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
3470
3576
  `release.yml`, Dependabot, and issue templates
3471
3577
 
3472
- [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.29...HEAD
3578
+ [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.31...HEAD
3579
+ [1.4.31]: https://github.com/bymaxone/nest-logger/compare/v1.4.30...v1.4.31
3580
+ [1.4.30]: https://github.com/bymaxone/nest-logger/compare/v1.4.29...v1.4.30
3473
3581
  [1.4.29]: https://github.com/bymaxone/nest-logger/compare/v1.4.28...v1.4.29
3474
3582
  [1.4.28]: https://github.com/bymaxone/nest-logger/compare/v1.4.27...v1.4.28
3475
3583
  [1.4.27]: https://github.com/bymaxone/nest-logger/compare/v1.4.26...v1.4.27
package/README.md CHANGED
@@ -270,7 +270,7 @@ A key that holds `undefined` or `null` is read as not set, in the options and in
270
270
  | `resourceFormat` | `'nested' \| 'flat'` | `'nested'` | Shape of the identity fields. `'flat'` emits the dotted attribute names verbatim |
271
271
  | `eventNameField` | `string \| false` | `'event.name'` | Field carrying the derived event name (`PAYMENT_FAILED` → `payment.failed`). `false` disables it |
272
272
  | `errorFormat` | `'pino' \| 'semconv' \| 'both'` | `'pino'` | `'both'` adds `exception.*` and `error.type` beside `err.*`; `'semconv'` replaces them |
273
- | `level` | `LogLevel` | `'info'` when `NODE_ENV=production`, else `'debug'` | Minimum log level. One of `fatal \| error \| warn \| info \| debug \| trace` |
273
+ | `level` | `LogLevel` | `'info'` when `NODE_ENV=production`, else `'debug'` | Minimum log level. One of `fatal \| error \| warn \| info \| debug \| trace`, in lower case. Anything else, such as Pino's `silent`, `'FATAL'` or a numeric level, makes `forRoot` throw when it is called, and `forRootAsync` throw at bootstrap |
274
274
  | `redactPaths` | `string[]` | `[]` | Additional `fast-redact` paths, applied on top of the default coverage |
275
275
  | `redactStrategy` | `'names' \| 'paths'` | `'names'` | Engine behind the DEFAULT set. `'paths'` is the legacy `fast-redact` expansion (four-level ceiling, much slower) |
276
276
  | `shouldDisableDefaultRedact` | `boolean` | `false` | Skip the default PII coverage entirely. ⚠️ Emits `LOGGER_BOOTSTRAP_WARNING` at startup — document why |
@@ -373,7 +373,7 @@ The levels are `info` for `HTTP_REQUEST_START`, `HTTP_REQUEST_SUCCESS` and `HTTP
373
373
 
374
374
  URLs are normalized (`/users/550e8400-e29b-41d4-a716-446655440000` becomes `/users/:id`) so label cardinality stays bounded. The **query string is stripped** from every logged URL and from the message of a logged exception, because a magic-link token in a query parameter is a secret no key-name redaction can scrub out of a string. Only a literal `?` starts a query. A path segment that looks like a credential (a long hex value, a JWT, an opaque token, an email address, or a dotted token such as `ya29.…` or `v4.local.…` of which any dot-separated part is a long opaque token) is written as `:redacted` in `url`, `fullUrl` and the not-found message, and `http.secretPathSegments` adds your own patterns. `fullUrl` is the raw path without its query and with those segments replaced, not the request as received. A long camelCase or Pascal-case name cannot be told from a token and is replaced too. A secret the rules cannot see, such as `;jsessionid=...` in a segment, stays in `url`, and the message of a 5xx error is the application's own text, which is not scrubbed.
375
375
 
376
- For a body that does not parse (`entity.parse.failed`), one the parser's `verify` refuses (`entity.verify.failed`), or an unsupported content encoding or charset, `HTTP_EXCEPTION_HANDLED` carries a fixed message and the parser `type` in `bodyParserType`, because the parser's message can quote part of the body. While `HttpExceptionFilter` is registered it also writes the response: an `HttpException` keeps its own body, a thrown value that exposes a 4xx status becomes `{ statusCode, message }`, and any other error becomes `500 { statusCode: 500, message: 'Internal server error' }`; the application owns the response only when it registers no such filter. The malformed-JSON case needs the Express adapter and a body parser mounted before `app.init()`, as Nest's default one is; with another adapter, or a parser mounted after `app.init()`, that entry keeps the parser's message.
376
+ For a body that does not parse (`entity.parse.failed`), one the parser's `verify` refuses (`entity.verify.failed`), or an unsupported content encoding or charset, `HTTP_EXCEPTION_HANDLED` carries a fixed message and the parser `type` in `bodyParserType`, because the parser's message can quote part of the body. While `HttpExceptionFilter` is registered it also writes the response: an `HttpException` keeps its own body, a thrown value that exposes a 4xx status becomes `{ statusCode, message }`, and any other error becomes `500 { statusCode: 500, message: 'Internal server error' }`; the application owns the response only when it registers no such filter. The malformed-JSON case needs the Express adapter and a body parser mounted before `app.init()`, as Nest's default one is. The Fastify adapter is not supported: measured with `@nestjs/platform-fastify` 11.2.9 (Fastify 5.12.8), the same malformed body reaches `HTTP_EXCEPTION_HANDLED` with Fastify's own message and no `bodyParserType`, and the filter's response fails with `res.status(...).json is not a function`. A parser mounted after `app.init()` sits behind the router, so it never runs for a route that matches: that route handles the request without a parsed body (measured: a malformed JSON body to a route answered `201`, and no `HTTP_EXCEPTION_HANDLED` entry was written).
377
377
 
378
378
  > [!IMPORTANT]
379
379
  > **Why middleware and not an interceptor.** NestJS runs middleware → guards → interceptors → handler, so an interceptor never sees a request a guard rejected or one that matched no route. Measured against a real backend, 401, 403, 429 and 404 produced no log line at all, which hid brute force and route enumeration. Without the middleware wiring, the interceptor-based behaviour remains, blind spot included.
@@ -879,7 +879,7 @@ The library censors **62 sensitive field names** wherever they appear in a recor
879
879
  | Other spellings | `access_token`, `refresh_token`, `id_token`, `api_key`, `apikey`, `api_secret`, `client_secret`, `signing_secret`, `private_key`, `secret_key`, `secretKey`, `access-token`, `refresh-token`, `id-token`, `api-key`, `client-secret`, `private-key`, `proxy-authorization`, `session_token`, `sessionToken`, `sessiontoken`, `session-token`, `x-csrf-token`, `x-xsrf-token`, `csrf_token`, `csrfToken`, `csrf-token`, `password_hash`, `new_password`, `old_password` |
880
880
  | HTTP headers (absolute) | `req.headers.authorization`, `req.headers.cookie`, `req.headers["x-api-key"]`, `req.headers["x-auth-token"]`, `res.headers["set-cookie"]` — retained for the legacy `'paths'` strategy; the by-name row above already covers these shapes and every other |
881
881
 
882
- Redaction is one **recursive, snapshotting walk**: a value is censored when its key name is in the set, wherever it sits. A name and a key are compared in one folded form: the case, every character that is not a letter or a digit (the separators `_`, `.` and `-` and every other dash, mark and punctuation), white space, control and zero-width characters, combining marks, the compatibility forms Unicode defines and a list of letters drawn like a Latin one are read through, and a letter that is not ASCII and that the list does not read as one Latin letter stands for one or two letters (in a key no longer than the longest name; a key longer than every name is never taken for one, so a field of another script is hidden when it is short, which is the price of never letting a spelling of a name through, and kept when it is long), so a key that has one is hidden by a name it matches everywhere else; the keys the entry owns are compared exactly after folding, so a caller field is never dropped for looking like one, so a key that has one is hidden by a name of a compatible length that matches it everywhere else (`autһorization` is hidden by `authorization`, and a key of the same length that only shares its ASCII letters is hidden too), so `apiKey` also hides `api_key`, `API-KEY`, `api\u200bKey` and `\u0430piKey`, and a name hides the field however an untrusted payload spells it. A key that spells a configured name another way is the same name, so a field whose name only differs in those ways is hidden too. Under `redactStrategy: 'paths'` the paths are matched exactly by `fast-redact`: literally, with no folding of case, separators or look-alikes, and none of this applies. Nothing the caller passed is mutated, and every value is read once and pinned into a fresh structure, so what reaches the sink is what was inspected even when the payload carries accessors or a `toJSON` that could answer differently on a second read. A value with a `toJSON` is inspected through that method's output; when the source object itself carries a sensitive key, the method is not trusted and the whole value is censored, because a method could rename what it exposes. `DEFAULT_REDACT_PATHS` is still exported at full fidelity, and `redactStrategy: 'paths'` feeds it to `fast-redact` for anyone depending on exact path semantics, with a four-level ceiling and a much higher cost.
882
+ Redaction is one **recursive, snapshotting walk**: a value is censored when its key name is in the set, wherever it sits. A name and a key are compared in one folded form: the case, every character that is not a letter or a digit (the separators `_`, `.` and `-` and every other dash, mark and punctuation), white space, control and zero-width characters, combining marks, the compatibility forms Unicode defines, the negative circled and squared letters and the regional indicators (read as their Latin letter), a symbol that is not ASCII and is no letter (read as a character that stands for nothing, one or two characters of a name) and a list of letters drawn like a Latin one are read through, and a letter that is not ASCII and that the list does not read as one Latin letter stands for one or two letters (in a key no longer than the longest name; a key longer than every name is never taken for one, so a field of another script is hidden when it is short, which is the price of never letting a spelling of a name through, and kept when it is long), so a key that has one is hidden by a name it matches everywhere else; the keys the entry owns are compared exactly after folding, so a caller field is never dropped for looking like one, so a key that has one is hidden by a name of a compatible length that matches it everywhere else (`autһorization` is hidden by `authorization`, and a key of the same length that only shares its ASCII letters is hidden too), so `apiKey` also hides `api_key`, `API-KEY`, `api\u200bKey` and `\u0430piKey`, and a name hides the field however an untrusted payload spells it. A `redactPaths` entry is at most 256 characters (a longer one is refused at startup by option name, without its value). A key that spells a configured name another way is the same name, so a field whose name only differs in those ways is hidden too. Under `redactStrategy: 'paths'` the paths are matched exactly by `fast-redact`: literally, with no folding of case, separators or look-alikes, and none of this applies. Nothing the caller passed is mutated, and every value is read once and pinned into a fresh structure, so what reaches the sink is what was inspected even when the payload carries accessors or a `toJSON` that could answer differently on a second read. A value with a `toJSON` is inspected through that method's output; when the source object itself carries a sensitive key, the method is not trusted and the whole value is censored, because a method could rename what it exposes. `DEFAULT_REDACT_PATHS` is still exported at full fidelity, and `redactStrategy: 'paths'` feeds it to `fast-redact` for anyone depending on exact path semantics, with a four-level ceiling and a much higher cost.
883
883
 
884
884
  > [!NOTE]
885
885
  > A bare `sessionId`, `session_id` or `session-id` is **not** on the list: many applications carry one as a correlation key, and a name cannot be switched off one at a time. A session id that is itself a bearer credential in your system must be added to your own `redactPaths` (`redactPaths: ['sessionId']` censors it at any depth under the default strategy).
@@ -964,6 +964,10 @@ logger.warnStructured('AUTH_REUSE_DETECTED', 'token family revoked after reuse d
964
964
 
965
965
  An interpolated value has no name, so no configuration can redact it. **A value that matters is a field, not text.** A field can be redacted, queried and correlated; inside `msg` it can only be read by a human. The library cannot enforce this, because the decision is made at the call site.
966
966
 
967
+ **A key planted on `Object.prototype` is no option.** The options are read as you set them: a value that only the root of a prototype chain holds is skipped, so a pollution cannot turn default redaction off or change the censor. One limit stays, and it is Pino's: a key planted by plain assignment (so it is enumerable) under `level`, `levels`, `msgPrefix` or `levelVal` makes Pino throw: under `level`, `msgPrefix` or `levelVal` (which is read-only) **while the logger is built**, at startup, and under `levels` at the first call of the Nest-style methods (`log`, `warn`, `error`...), because Pino assigns every key a `for...in` over its level table finds to its instance. Others are Pino's and Node's own: a `hasOwnProperty` planted as something that is not a function makes Pino throw while it is built, and so does a `message` that is not a function, which Node's event emitter reaches through the destination streams. All of them fail loudly, write nothing and un-redact nothing. A built-in that the redaction reads and that a program replaces after the import drops the record, and redacts a URL path whole: before each record each one in the table (`GUARDED_BUILTINS` in `src/server/utils/captured-builtins.util.ts`, which a spec holds to the calls of `fold-key`, `normalize-url`, `matches-exclude-path`, `sanitize-error` and `pino-factory`) is compared with the one the module loaded with, and a logger is not built, nor its options resolved, while one differs. The table does not cover what `redact-by-name`, the error-text exemption, `redact-error-parts`, the mixin merge, the truncation and `bounded-text` call (`Object.assign`, `Function.prototype.call`, `Set.prototype.delete`, `charCodeAt`...); a program that replaces those can make a log call throw into the host, and none was found to let a value through. A value whose prototype chain does not end within the bound in `resolve-to-json.util.ts` is written as the censor. An error stack fails closed too, since the message would stay in its first line. What a program replaced **before** it imported the logger is what the logger loads with, and is outside the guard. The guard is against a pollution done by assignment, which plants data; a getter or a setter installed with `Object.defineProperty`, and a property made read-only, are outside it.
968
+
969
+ These guards are best-effort hardening against prototype pollution and replaced built-ins, not a security boundary: code running inside the host process is trusted, as in Node's own threat model. See [SECURITY.md](./SECURITY.md#threat-model-same-process-code).
970
+
967
971
  ### A closed pipe does not kill the process
968
972
 
969
973
  `node app | head` closes the read end of stdout while the application is still writing. Node reports the `EPIPE` asynchronously through the stream's `'error'` event, after `write()` returned, and attaches no default handler to `process.stdout`, so the emit becomes an uncaught exception and the process dies. Every write the library makes to a process stream (default stdout sink, last-resort rescue, pre-init drain, `stderr` reports) installs a swallowing `'error'` listener on first use. The one exception is the stream `pino-pretty` writes through, which attaches listeners of its own. The side effect: the listener sits on the shared `process.stdout`, so an EPIPE raised by your own writes stops being an uncaught exception too. Your own `'error'` listener is never removed or replaced. A custom `ILogDestination` that writes to `process.stdout` should do the same; the [destinations guide](./docs/guidelines/DESTINATIONS-IMPLEMENTATION-GUIDELINES.md) has the pattern.
@@ -1237,20 +1241,20 @@ Two kinds of failure, and they surface differently. A **thrown `Error`** carries
1237
1241
 
1238
1242
  ### Thrown errors
1239
1243
 
1240
- | Message starts with | Thrown from | When | Action |
1241
- | -------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
1242
- | `[BymaxLoggerModule] options.` | `forRoot` / `forRootAsync`, at module setup | any option fails validation: a missing `service`, a `level` outside the set, a bad type | Fix the option the message names; it prints the path and what it received |
1243
- | `[BymaxLoggerModule] options could not be read` | `forRoot` / `forRootAsync`, at module setup | an option the host supplies threw when it was read (a getter or a Proxy trap) | Fix the option; the error the host threw is the `cause` |
1244
- | `holds more than` | `forRoot` / `forRootAsync`, at module setup | a list option (`redactPaths`, `errorOwnFieldNames`, `destinations`, `http.excludePaths`, `http.secretPathSegments`) is longer than 10,000 entries | Shorten the list; it is refused before any element is read |
1245
- | `has a length that is not a count` | `forRoot` / `forRootAsync`, at module setup | a list option reports a length that is negative, fractional, `NaN` or infinite (a Proxy; an array never does) | Fix the option; it is refused before any element is read |
1246
- | `[BymaxLoggerModule] useNestLogger(app) called but` | `BymaxLoggerModule.useNestLogger` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1247
- | `[BymaxLoggerModule] applyAccessLog(app) called but` | `applyAccessLog` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1248
- | `[BymaxLoggerModule] useRequestContext(app) called but` | `useRequestContext` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1249
- | `[PrettyDevDestination] pino-pretty is not installed` | `PrettyDevDestination.onInit` | the destination is registered and resolving `pino-pretty` itself fails | Install `pino-pretty` or drop the destination |
1250
- | `[PrettyDevDestination] pino-pretty failed to start` | `PrettyDevDestination.onInit` | `pino-pretty` is found but importing it or building the transform throws | Read the message and the error's `cause`: it is the real failure |
1251
- | `[PrettyDevDestination] refused in production` | `PrettyDevDestination.onInit` | `NODE_ENV` is exactly `production` | Use `DefaultStdoutDestination` in production |
1252
- | `[LogContextService] set() called outside run() scope` | `LogContextService.set` | called with no active `run()` | Wrap the work in `logContext.run({ ... }, () => ...)` |
1253
- | `[LogContextService] Refusing to set unsafe context key` | `LogContextService.set` | the key is `__proto__`, `constructor` or `prototype` | Use an ordinary key |
1244
+ | Message starts with | Thrown from | When | Action |
1245
+ | -------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
1246
+ | `[BymaxLoggerModule] options.` | `forRoot` / `forRootAsync`, at module setup | any option fails validation: a missing `service`, a `level` outside the set, a bad type | Fix the option the message names; it prints the path and what it received |
1247
+ | `[BymaxLoggerModule] options could not be read` | `forRoot` / `forRootAsync`, at module setup | an option the host supplies threw when it was read (a getter or a Proxy trap) | Fix the option; the error the host threw is the `cause` |
1248
+ | `holds more than` | `forRoot` / `forRootAsync`, at module setup | a list option is longer than the entry cap (`MAX_LIST_ENTRIES`) | Shorten the list; it is refused before any element is read |
1249
+ | `has a length that is not a count` | `forRoot` / `forRootAsync`, at module setup | a list option reports a length that is negative, fractional, `NaN` or infinite (a Proxy; an array never does) | Fix the option; it is refused before any element is read |
1250
+ | `[BymaxLoggerModule] useNestLogger(app) called but` | `BymaxLoggerModule.useNestLogger` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1251
+ | `[BymaxLoggerModule] applyAccessLog(app) called but` | `applyAccessLog` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1252
+ | `[BymaxLoggerModule] useRequestContext(app) called but` | `useRequestContext` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1253
+ | `[PrettyDevDestination] pino-pretty is not installed` | `PrettyDevDestination.onInit` | the destination is registered and resolving `pino-pretty` itself fails | Install `pino-pretty` or drop the destination |
1254
+ | `[PrettyDevDestination] pino-pretty failed to start` | `PrettyDevDestination.onInit` | `pino-pretty` is found but importing it or building the transform throws | Read the message and the error's `cause`: it is the real failure |
1255
+ | `[PrettyDevDestination] refused in production` | `PrettyDevDestination.onInit` | `NODE_ENV` is exactly `production` | Use `DefaultStdoutDestination` in production |
1256
+ | `[LogContextService] set() called outside run() scope` | `LogContextService.set` | called with no active `run()` | Wrap the work in `logContext.run({ ... }, () => ...)` |
1257
+ | `[LogContextService] Refusing to set unsafe context key` | `LogContextService.set` | the key is `__proto__`, `constructor` or `prototype` | Use an ordinary key |
1254
1258
 
1255
1259
  The `PrettyDevDestination` errors are thrown inside `onInit`, which the registry contains: the boot continues and the failure is reported as `LOGGER_DESTINATION_INIT_FAILED` below.
1256
1260
 
@@ -15,6 +15,8 @@ var __decorateClass = (decorators, target, key, kind) => {
15
15
  return result;
16
16
  };
17
17
  var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
18
+ var IntrinsicPromise = Object.getPrototypeOf((async () => void 0)()).constructor;
19
+ var define = Object.defineProperty;
18
20
  var LOGGER_HEALTH_INDICATOR_NAME = "logger";
19
21
  exports.LoggerHealthIndicator = class LoggerHealthIndicator {
20
22
  /**
@@ -31,10 +33,21 @@ exports.LoggerHealthIndicator = class LoggerHealthIndicator {
31
33
  */
32
34
  check() {
33
35
  const { destinations, failedInit, writeFailing, hasHealthySink } = this.observability.deliveryState();
34
- return Promise.resolve({
36
+ const verdict = Object.freeze({
37
+ __proto__: null,
35
38
  status: hasHealthySink ? "up" : "down",
36
- details: { destinations, failedInit, writeFailing }
39
+ details: Object.freeze({ destinations, failedInit, writeFailing })
37
40
  });
41
+ const answer = new IntrinsicPromise((resolve) => {
42
+ resolve(verdict);
43
+ });
44
+ define(answer, "constructor", {
45
+ __proto__: null,
46
+ value: IntrinsicPromise,
47
+ writable: false,
48
+ configurable: false
49
+ });
50
+ return answer;
38
51
  }
39
52
  };
40
53
  exports.LoggerHealthIndicator = __decorateClass([
@@ -13,6 +13,8 @@ var __decorateClass = (decorators, target, key, kind) => {
13
13
  return result;
14
14
  };
15
15
  var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
16
+ var IntrinsicPromise = Object.getPrototypeOf((async () => void 0)()).constructor;
17
+ var define = Object.defineProperty;
16
18
  var LOGGER_HEALTH_INDICATOR_NAME = "logger";
17
19
  var LoggerHealthIndicator = class {
18
20
  /**
@@ -29,10 +31,21 @@ var LoggerHealthIndicator = class {
29
31
  */
30
32
  check() {
31
33
  const { destinations, failedInit, writeFailing, hasHealthySink } = this.observability.deliveryState();
32
- return Promise.resolve({
34
+ const verdict = Object.freeze({
35
+ __proto__: null,
33
36
  status: hasHealthySink ? "up" : "down",
34
- details: { destinations, failedInit, writeFailing }
37
+ details: Object.freeze({ destinations, failedInit, writeFailing })
35
38
  });
39
+ const answer = new IntrinsicPromise((resolve) => {
40
+ resolve(verdict);
41
+ });
42
+ define(answer, "constructor", {
43
+ __proto__: null,
44
+ value: IntrinsicPromise,
45
+ writable: false,
46
+ configurable: false
47
+ });
48
+ return answer;
36
49
  }
37
50
  };
38
51
  LoggerHealthIndicator = __decorateClass([