input-output-logger: replacer function is not called
iloewensen opened this issue · comments
Ingmar commented
Describe the bug
The replacer function of input-output-logger middleware is not called
To Reproduce
test('It should call replacer', async (t) => {
const logger = sinon.spy()
const replacer = sinon.spy()
const handler = middy((event) => event).use(
inputOutputLogger({
logger,
replacer
})
)
const event = { foo: 'bar', fuu: 'baz' }
const response = await handler(event, context)
t.true(logger.calledWithExactly({ event }))
t.true(logger.calledWithExactly({ response: event }))
t.true(replacer.calledWith({ event }))
t.deepEqual(response, event)
})
Expected behaviour
The replacer is called
Environment
- Node.js: 20.12
- Middy: 5.3.2
Additional context
will Farrell commented
Thanks for reporting. In v4 we used JSON.parse(JSON.stringify(message, replacer))
to deep clone the object. In v5 we use the newer structuredClone(message)
. The replacer
option should have been removed in v5, sorry about the confusion.
Ingmar commented
@willfarrell it would be helpful to update the documentation :)
https://middy.js.org/docs/middlewares/input-output-logger
will Farrell commented
I've now triggered the docs to rebuild.