Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deserializeError serializes/destroys properties unnecessarily #76

Open
fregante opened this issue May 9, 2022 · 1 comment
Open

deserializeError serializes/destroys properties unnecessarily #76

fregante opened this issue May 9, 2022 · 1 comment

Comments

@fregante
Copy link
Contributor

fregante commented May 9, 2022

This module is set up in a weird way. destroyCircular is called both when serializing and deserializing and it's doing two separate things:

The second part part is particularly problematic because during deserialization, this module is potentially dropping functions and all other "supported" types like buffer. This is unexpected:

deserializeError({
	name: 'Error'
	message: '💩',
	data: new Buffer([1,2,3])
});
// [Error: 💩] with `data` property of value "[object Buffer]"

I'd expect the string "[object Buffer]" when serializing an error, not during deserialization.

@fregante
Copy link
Contributor Author

fregante commented May 9, 2022

The new serialize option in destroyCircular sets this up for a simple fix, even though it would probably benefit from a rewrite.

https://github.com/sindresorhus/serialize-error/pull/73/files#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346R62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants