Skip to content

fix(logger): handle bare null-prototype metadata messages - #2655

Open
sergioperezcheco wants to merge 1 commit into
winstonjs:masterfrom
sergioperezcheco:fix/null-prototype-meta-message-20261019
Open

sergioperezcheco wants to merge 1 commit into
winstonjs:masterfrom
sergioperezcheco:fix/null-prototype-meta-message-20261019

Conversation

@sergioperezcheco

Copy link
Copy Markdown

The reproduction in #2267 throws before formats or transports can receive the record: concatenating meta.message fails when it is a bare null-prototype dictionary. Use the existing safe-stable-stringify dependency for those dictionaries, including circular ones, while retaining ordinary object/string conversion and user-defined hooks. This is deliberately limited to direct null-prototype objects without conversion properties; proxies and other coercion failures keep their existing behavior.

The conversion check does not invoke hook getters or inspect proxies. Browser util shims can expose an isProxy function that throws, so proxy-detection capability is probed once on an internal object. Without that capability the original conversion behavior is retained, including the existing null-prototype error; this change does not claim to fix that browser case.

Regression tests cover the original crash, circular dictionaries, ordinary conversion, getter read counts, exact user-exception propagation, proxy traps, metadata preservation, and missing/throwing util shims. On Node 22/macOS, the logger tests, public Stream/JSON round trips, lint, TypeScript checks, integration tests, and Babel build pass. All 20 unit suites complete with 254 passing tests and 3 todos, but Jest does not exit naturally because of an existing tail-file timer; the pristine baseline also exhibits this problem. The real util@0.12.5 shim was checked against source and built code through Node module resolution, not a browser runtime. Other CI platforms and Node versions remain for CI.

AI-assisted implementation and independent automated review used Hermes; no human review is claimed. Fixes #2267 for the Node reproduction described above.

Preserve custom coercion and proxy behavior, including util shims without proxy detection.

Assisted-by: Hermes
Signed-off-by: sergioperezcheco <checo520@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Issue with meta.message when a null prototype object is passed

1 participant