Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pino-http

Package Overview
Dependencies
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-http - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

9

logger.js

@@ -49,2 +49,8 @@ 'use strict'

function onReqAborted () {
var res = this.res
res.statusCode = 408
onResFinished.call(res, new Error('Aborted'))
}
function loggingMiddleware (req, res, next) {

@@ -54,5 +60,8 @@ req.id = genReqId(req)

res.startTime = Date.now()
if (!req.res) { req.res = res }
res.on('finish', onResFinished)
res.on('error', onResFinished)
// it's possible that browser aborts connection, or http-server because of timeout
req.on('aborted', onReqAborted)

@@ -59,0 +68,0 @@ if (next) {

2

package.json
{
"name": "pino-http",
"version": "2.2.0",
"version": "2.3.0",
"description": "High-speed HTTP logger for Node.js",

@@ -5,0 +5,0 @@ "main": "logger.js",

@@ -32,3 +32,3 @@ 'use strict'

var address = server.address()
http.get('http://' + address.address + ':' + address.port)
return http.get('http://' + address.address + ':' + address.port)
}

@@ -261,1 +261,74 @@

})
test('react on aborted event from clientside', function (t) {
var dest = split(JSON.parse)
var idToTest
function genReqId (req) {
t.ok(req.url, 'The first argument must be the request parameter')
idToTest = (Date.now() + Math.random()).toString(32)
return idToTest
}
var logger = pinoHttp({
logger: pino({
serializers: pino.stdSerializers
}, dest),
genReqId: genReqId
})
setup(t, logger, function (err, server) {
t.error(err)
var address = server.address()
var request = http.get({
host: address.address,
port: address.port
})
// need this in order to prevent unhadled socket handup
request.on('error', function () {})
setTimeout(function () {
// break the connection from the clientside
request.abort()
}, 100)
}, logger)
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.end()
})
})
test('react on aborted event from server', function (t) {
var dest = split(JSON.parse)
var idToTest
function genReqId (req) {
t.ok(req.url, 'The first argument must be the request parameter')
idToTest = (Date.now() + Math.random()).toString(32)
return idToTest
}
var logger = pinoHttp({
logger: pino({
serializers: pino.stdSerializers
}, dest),
genReqId: genReqId
})
setup(t, logger, function (err, server) {
server.timeout = 100
t.error(err)
var request = doGet(server)
// need this in order to prevent unhadled socket handup
request.on('error', function () {})
}, logger)
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.end()
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc