Repository navigation
fix: keep a Date in log metadata instead of writing {} (2.2.1) - #153
Merged
Merged
Conversation
From 2.0.0 the logger-level error format rebuilt every metadata object
from its own enumerable keys, and a Date has none, so every Date reached
every transport as `{}` — a TypeORM query parameter, a timestamp field,
anything. 1.x left them for the JSON step, which writes the ISO string.
A value that defines `toJSON` is now passed through the metadata walk as
the same reference, as 1.x did. Inside a serialized error, where the
output must be plain, it is replaced by what its `toJSON` returns: a Date
becomes its ISO string, an invalid one `null`, a URL its href. An error
is never asked for its `toJSON`, so an AxiosError-style error is still
captured whole.
Fixes #152
Advisories published since 2.2.0 fail `npm run audit`, which both the PR workflow and the publish workflow run before anything else, so no release could ship. All are in dev tooling: brace-expansion, fast-uri, fflate, shell-quote, source-map-js, @humanfs/node (lockfile only), and vitest / @vitest/coverage-v8 4.1.4 → 4.1.12. The fflate fix (0.8.2 → 0.8.3) changes how its streaming gunzip emits chunks and breaks attw 0.18.2's tarball parsing, so attw moves to 0.18.5, which targets fflate 0.8.3.
3 tasks done
robdmoore
approved these changes
Oct 16, 2026
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #152.
What
From 2.0.0 to 2.2.0, any
Datein log metadata reached every transport as{}.serializeErrorFormatruns first at the logger level, and its metadata walk rebuilds every object fromObject.keys; aDatehas no own enumerable keys. 1.x left metadata alone and the JSON step wrote the ISO string.How
serializeErrorFormat): a value that definestoJSON—Date,URL, a date-library instance — is passed through as the same reference, as 1.x did. A transport receives theDate; the console'sformat.json,flattenand any other JSON step write its ISO string.serializeError): output must be plain, so atoJSONvalue on an error is replaced by what it returns — ISO string,nullfor an invalidDate,hreffor aURL. WhentoJSONthrows or returns the value itself, the own-keys walk runs as before.toJSON, so an error class that defines one (anAxiosError, say) is still captured whole —name,message,stackand its own fields — rather than as whatever itstoJSONchooses to show.index.tsdoes not re-export, so the public API is unchanged.Also: unblocks CI and publishing
Advisories published since 2.2.0 make
npm run auditfail, and both the PR workflow andpublish.ymlrun it first, so main could not publish anything. All nine are in dev tooling. A non-forcingnpm audit fixclears the lockfile-only ones;vitest/@vitest/coverage-v8move 4.1.4 → 4.1.12. The fflate fix (0.8.2 → 0.8.3) breaks attw 0.18.2's tarball parsing (Cannot read properties of undefined (reading 'filename')), so@arethetypeswrong/climoves to 0.18.5, which targets fflate 0.8.3.Version
2.2.1 — patch. It restores 1.x behaviour; no output that was correct in 2.2.0 changes. Publishing happens on merge (
publish.yml). This should merge before the 2.3.0 OTel PR, which is stacked on this branch.Test plan
npm run build— lint,tsc, rollup,attw --pack, CJS smoke testnpm test— 154 tests. The 8 new tests that exercise the bug fail againstmain's source and pass here; 3 guard tests (an error withtoJSONin the format and in the serializer, atoJSONthat throws) pass on bothtimestamptzparameters and carries a workaround that this makes removable