davidmarkclements / fast-safe-stringify

Safely and quickly serialize JavaScript objects
MIT License
348 stars 27 forks source link

Not enumerated properties are not detected by circular detection #53

Closed szwalkowski closed 3 years ago

szwalkowski commented 3 years ago

Like errors from GOT that have properties that are not returned by Object.keys. How about using Object.getOwnPropertyNames in 'decirc' ?

And JSON.stringify do go over those properties

https://stackoverflow.com/questions/18277890/why-cant-i-see-the-keys-of-an-error-object

mcollina commented 3 years ago

Would you like to send a PR?

szwalkowski commented 3 years ago

Ofc :) Btw I was thinking if it should be behind some configuration? Do you think would be necessary to be sure that it won't break anything for current users? Thou I was thinking about various scenarios, output should be the same for ppl - even with custom replacers. So maybe hiding that behind configuration is not needed

mcollina commented 3 years ago

Can you give an example of what is not working?

szwalkowski commented 3 years ago

Okay, it happened that we had bug in replacer. We were using in replacer Object.getOwnPropertyNames - and we saw printed not enumerable properties - while I claimed that JSON.stringify goes over those - and I was wrong - it does not. Sorry for missunderstanding.