villadora / express-bunyan-logger

bunyan logger middleware for express
139 stars 74 forks source link

Eliminate Node12 header deprecation warning (DEP0066) #57

Open twhitner-vistaprint opened 5 years ago

twhitner-vistaprint commented 5 years ago

https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames

zorji commented 4 years ago

Do you mind use the solution here so that it doesn't need an extra dependency?

https://github.com/newrelic/node-newrelic/blob/0113eb5f0e707dc662a17d262a841503bab88841/lib/instrumentation/core/http.js#L214

  'res-headers': (res.getHeaders && res.getHeaders()) || res._headers,
cesine commented 3 years ago

We are also looking forward to this fix, @twhitner-vistaprint are you free to update the pr to use the simplified logic @zorji suggested?


(node:45346) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
...
(node:45363) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
    at ServerResponse.logging (~/myapp/node_modules/express-bunyan-logger/index.js:130:36)
    at ServerResponse.emit (events.js:327:22)
    at ServerResponse.EventEmitter.emit (domain.js:486:12)
    at onFinish (_http_outgoing.js:766:10)
    at callback (_stream_writable.js:513:21)
    at afterWrite (_stream_writable.js:466:5)
    at afterWriteTick (_stream_writable.js:453:10)
    at processTicksAndRejections (internal/process/task_queues.js:79:21)

``
chaudhryjunaid commented 3 years ago

I have merged the fix in my own updated fork at: https://www.npmjs.com/package/@chaudhryjunaid/express-bunyan-logger