Use fclone
to do serialization and prevent circular references
#5
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.
Using solution at #4 found the problem of
Error
objectsname
andstack
fields (and for native errorsmessage
fields too) were not being included because they are non-enumerable, leading to native errors with an empty objects. Due to this, I've taken the path to prevent circular references and decided to use the https://www.npmjs.com/package/fclone module, since doesn't have any dependency and seems to have a good usage popularity. I can confirm that this works as expected, showing the missing fields inError
objects (code has an explicit check for them), and circular object references are replaced by a[Circular]
string.I've done this in a new pull-request since previous one is hosted on my company Github organization and I don't have write access to it anymore.