Skip to content

Commit efd618d

Browse files
fix: added structuredClone check
1 parent b6c217a commit efd618d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/req.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ const headerRedact = fastRedact({
1919
'["x-forwarded-for"]',
2020
'["proxy-authorization"]'
2121
],
22-
serialize: (val) => JSON.parse(JSON.stringify(val))
22+
serialize: (val) => typeof structuredClone === 'function'
23+
? structuredClone(val)
24+
: JSON.parse(JSON.stringify(val))
2325
})
2426

2527
const rawSymbol = Symbol('pino-raw-req-ref')

lib/res.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ const headerRedact = fastRedact({
1313
'["x-real-ip"]',
1414
'["x-forwarded-for"]'
1515
],
16-
serialize: (val) => JSON.parse(JSON.stringify(val))
16+
serialize: (val) => typeof structuredClone === 'function'
17+
? structuredClone(val)
18+
: JSON.parse(JSON.stringify(val))
1719
})
1820

1921
const rawSymbol = Symbol('pino-raw-res-ref')

0 commit comments

Comments
 (0)