pinojs / pino-noir

🌲 pino log redaction 🍷
MIT License
66 stars 17 forks source link

pino-noir hangs the server (redacting req.headers) #1

Closed floridemai closed 7 years ago

floridemai commented 7 years ago

Tried to use pino-noir in the following way:

  opts.serializers = noir([
    'created',
    'req.headers.authorization'
  ], '[Redacted]')

Server hangs. Note that the created property is redacted on the server start event and the bug seems to kick in when having to deal with the request headers.

novemberborn commented 7 years ago

Is this with Hapi? I've tried to redact req.headers.cookie which seems to modify the actual outgoing request object, crashing Hapi.

mcollina commented 7 years ago

Can you please provide an example to reproduce the issue?

novemberborn commented 7 years ago

@mcollina see https://github.com/novemberborn/_pino-noir-hapi-repro.

I think there the issues are unrelated. The example given for Hapi causes seemingly infinite log output (probably a circular recursion problem). Uncomment https://github.com/novemberborn/_pino-noir-hapi-repro/blob/b0a40659bb2e4a3046095690d88f9c30cfbda3a9/index.js#L42 to see.

Redacting cookies is tricky because asReqValue needs to be copied out of hapi-pino. But then if the cookie is present, it actually crashes Hapi. See: https://github.com/novemberborn/_pino-noir-hapi-repro/blob/b0a40659bb2e4a3046095690d88f9c30cfbda3a9/index.js#L46:L48

Clone the repo, run npm install, and then node index.js. It should start a server at http://localhost:8000/hello.

davidmarkclements commented 7 years ago

ok here's the problem (thanks @novemberborn for the example)

This is going to be a tricky fix, but here's what I reckon is best for minimum impact

@mcollina I'd welcome less ugly ideas - bear in mind I still want to keep fast-safe-stringify legacy compatible (including older browsers etc) so using Symbols is out

kishoresanke commented 6 years ago

@mcollina / @davidmarkclements , I'm facing the same exact issue on hapi.. what was the resolution for this ?

Versions i'm using :-

├─┬ hapi-pino@2.1.1 │ └─┬ pino@4.10.3 ├── pino-noir@2.0.0