From e7c6319ca3f317cf2f9a4f46849bfae4b1df3d58 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Sun, 11 Jul 2021 12:33:24 +0200 Subject: [PATCH] use json-stringify-safe to avoid stable algorithm --- lib/tools.js | 2 +- package.json | 2 +- test/basic.test.js | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/tools.js b/lib/tools.js index 440afae24..6d7722820 100644 --- a/lib/tools.js +++ b/lib/tools.js @@ -5,7 +5,7 @@ const format = require('quick-format-unescaped') const { mapHttpRequest, mapHttpResponse } = require('pino-std-serializers') const SonicBoom = require('sonic-boom') -const stringifySafe = require('safe-stable-stringify') +const stringifySafe = require('json-stringify-safe') const { lsCacheSym, chindingsSym, diff --git a/package.json b/package.json index d2214c426..6c9c5f417 100644 --- a/package.json +++ b/package.json @@ -91,8 +91,8 @@ }, "dependencies": { "fast-redact": "^3.0.0", - "safe-stable-stringify": "^1.0.0", "flatstr": "^1.0.12", + "json-stringify-safe": "^5.0.1", "pino-std-serializers": "^3.1.0", "quick-format-unescaped": "^4.0.3", "sonic-boom": "^1.0.2" diff --git a/test/basic.test.js b/test/basic.test.js index 52d5e5db1..46c645172 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -592,8 +592,7 @@ test('children with same names render in correct order', async ({ equal }) => { equal(a, 3, 'last logged object takes precedence') }) -// https://github.com/pinojs/pino/pull/251 - use this.stringify -test('use `fast-safe-stringify` to avoid circular dependencies', async ({ same }) => { +test('use `json-stringify-safe` to avoid circular dependencies', async ({ same }) => { const stream = sink() const root = pino(stream) // circular depth @@ -601,10 +600,10 @@ test('use `fast-safe-stringify` to avoid circular dependencies', async ({ same } obj.a = obj root.info(obj) const { a } = await once(stream, 'data') - same(a, { a: '[Circular]' }) + same(a, { a: '[Circular ~]' }) }) -test('fast-safe-stringify must be used when interpolating', async (t) => { +test('json-stringify-safe must be used when interpolating', async (t) => { const stream = sink() const instance = pino(stream) @@ -613,7 +612,7 @@ test('fast-safe-stringify must be used when interpolating', async (t) => { instance.info('test %j', o) const { msg } = await once(stream, 'data') - t.equal(msg, 'test {"a":{"b":{"c":"[Circular]"}}}') + t.equal(msg, 'test {"a":{"b":{"c":"[Circular ~.a.b]"}}}') }) test('throws when setting useOnlyCustomLevels without customLevels', async ({ throws }) => {