Comparing version 2.3.0 to 2.4.0
@@ -27,3 +27,3 @@ 'use strict' | ||
function onResFinished (err) { | ||
function onResFinished (err, msg) { | ||
this.removeListener('finish', onResFinished) | ||
@@ -47,3 +47,3 @@ this.removeListener('error', onResFinished) | ||
responseTime: responseTime | ||
}, 'request completed') | ||
}, 'request ' + (msg || 'completed')) | ||
} | ||
@@ -53,4 +53,11 @@ | ||
var res = this.res | ||
onResFinished.call(res, null, 'aborted') | ||
} | ||
function onReqTimeout () { | ||
this.removeListener('aborted', onReqAborted) | ||
var res = this.res | ||
res.statusCode = 408 | ||
onResFinished.call(res, new Error('Aborted')) | ||
onResFinished.call(res, new Error('Timeout')) | ||
} | ||
@@ -66,4 +73,4 @@ | ||
res.on('error', onResFinished) | ||
// it's possible that browser aborts connection, or http-server because of timeout | ||
req.on('aborted', onReqAborted) | ||
req.socket.on('timeout', onReqTimeout.bind(req)) | ||
@@ -110,3 +117,3 @@ if (next) { | ||
return function genReqId (req) { | ||
return req.id || (nextReqId = (nextReqId % maxInt) + 1) | ||
return req.id || (nextReqId = (nextReqId + 1) & maxInt) | ||
} | ||
@@ -113,0 +120,0 @@ } |
{ | ||
"name": "pino-http", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "High-speed HTTP logger for Node.js", | ||
"main": "logger.js", | ||
"dependencies": { | ||
"pino": "^3.0.1" | ||
"pino": "^3.3.2" | ||
}, | ||
@@ -22,2 +22,5 @@ "devDependencies": { | ||
"author": "David Mark Clements", | ||
"contributors": [ | ||
"Matteo Collina <hello@matteocollina.com>" | ||
], | ||
"license": "MIT", | ||
@@ -24,0 +27,0 @@ "repository": { |
@@ -294,5 +294,3 @@ 'use strict' | ||
dest.on('data', function (line) { | ||
t.equal(line.msg, 'request errored', 'message is set') | ||
t.equal(line.err.message, 'Aborted', 'error message is set') | ||
t.equal(line.res.statusCode, 408, 'statusCode is 408') | ||
t.equal(line.msg, 'request aborted', 'message is set') | ||
t.end() | ||
@@ -302,3 +300,3 @@ }) | ||
test('react on aborted event from server', function (t) { | ||
test('react on timeout event from server', function (t) { | ||
var dest = split(JSON.parse) | ||
@@ -330,3 +328,3 @@ | ||
t.equal(line.msg, 'request errored', 'message is set') | ||
t.equal(line.err.message, 'Aborted', 'error message is set') | ||
t.equal(line.err.message, 'Timeout', 'error message is set') | ||
t.equal(line.res.statusCode, 408, 'statusCode is 408') | ||
@@ -333,0 +331,0 @@ t.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
20579
445
Updatedpino@^3.3.2