util: throw toJSON errors when formatting %j · nodejs/node@455e6f1 · GitHub
Skip to content

Commit 455e6f1

Browse files
committed
util: throw toJSON errors when formatting %j
Previously all errors resulting from JSON.stringify were treated as a proof for circularity of the object structure. That is not the case if the `toJSON` method of the object throws an error. Explicitly check for the exact error message when determining the object structure's cyclicity. PR-URL: #11708 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 98e54b0 commit 455e6f1

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

lib/util.js

Lines changed: 6 additions & 2 deletions

test/parallel/test-util-format.js

Lines changed: 10 additions & 0 deletions

0 commit comments

Comments
 (0)