Comparing version 3.0.1 to 3.1.0
@@ -31,4 +31,4 @@ 'use strict' | ||
function onResFinished (err) { | ||
this.removeListener('error', onResFinished) | ||
this.removeListener('finish', onResFinished) | ||
this.removeListener('error', onResFinished) | ||
@@ -38,6 +38,6 @@ var log = this.log | ||
if (err) { | ||
if (err || this.err || this.statusCode >= 500) { | ||
log.error({ | ||
res: this, | ||
err: err, | ||
err: err || this.err || new Error('failed with status code' + this.statusCode), | ||
responseTime: responseTime | ||
@@ -44,0 +44,0 @@ }, 'request errored') |
{ | ||
"name": "pino-http", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "High-speed HTTP logger for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "logger.js", |
16
test.js
@@ -212,2 +212,18 @@ 'use strict' | ||
setTimeout(function () { | ||
res.err = new Error('Some error') | ||
res.emit('finished') | ||
res.end() | ||
}, 100) | ||
} | ||
expectResponseTime(t, dest, logger, handle) | ||
}) | ||
test('responseTime for request emitting error event', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp(dest) | ||
function handle (req, res) { | ||
logger(req, res) | ||
setTimeout(function () { | ||
res.emit('error', new Error('Some error')) | ||
@@ -214,0 +230,0 @@ res.end() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25704
634