Preserve message and name when logging Error instances#175
Merged
Conversation
JSON.stringify only walks enumerable own properties, so Error instances
(whose message, name and stack are non-enumerable) serialize to {} or to
a partial object when subclasses add own props. This regressed
downstream logs after consumers picked up AWS SDK v3, whose errors are
real Error subclasses (vs. SDK v2 which set message/code as enumerable
own props).
Pass a JSON replacer in SimpleLogger.safeStringify that detects Error
values and returns a plain object with message and name alongside any
own enumerable props. Stack is intentionally omitted to keep log lines
compact and match prior behavior.
Add unit tests covering plain Error, Error subclasses with own props,
nested Errors, non-Error passthrough, and absence of stack.
Issue: WRLGS-19
Contributor
Hello maeldonn,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Contributor
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
DarkIsDude
approved these changes
Jun 24, 2026
francoisferrand
approved these changes
Jun 24, 2026
Contributor
Author
|
/approve |
Contributor
|
I have successfully merged the changeset of this pull request
The following branches have NOT changed:
This pull request did not target the following hotfix branch(es) so they
Please check the status of the associated issue WRLGS-19. Goodbye maeldonn. The following options are set: approve |
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.
JSON.stringify only walks enumerable own properties, so Error instances (whose message, name and stack are non-enumerable) serialize to {} or to a partial object when subclasses add own props. This regressed downstream logs after consumers picked up AWS SDK v3, whose errors are real Error subclasses (vs. SDK v2 which set message/code as enumerable own props).
Pass a JSON replacer in SimpleLogger.safeStringify that detects Error values and returns a plain object with message and name alongside any own enumerable props. Stack is intentionally omitted to keep log lines compact and match prior behavior.
Add unit tests covering plain Error, Error subclasses with own props, nested Errors, non-Error passthrough, and absence of stack.
Issue: WRLGS-19