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

http-request-context

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-request-context - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

15

index.js
const asyncHooks = require('async_hooks')
const TCPWRAP_NAME = 'TCPWRAP'
const callstackMap = {} // all callstack map

@@ -45,3 +46,3 @@ const TCPWrapCallstackContainers = {} // request root callstack

if (callstackMap[asyncId]) {
if (callstackMap[asyncId].type === 'TCPWRAP') {
if (callstackMap[asyncId].type === TCPWRAP_NAME) {
return asyncId

@@ -54,3 +55,3 @@ }

asyncHooks.createHook({
init (asyncId, type, triggerAsyncId) {
init (asyncId, type) {
const executionAsyncId = asyncHooks.executionAsyncId()

@@ -68,12 +69,2 @@

}
},
destroy (asyncId) {
// delete root & all callstack
if (TCPWrapCallstackContainers[asyncId]) {
delete callstackMap[asyncId]
TCPWrapCallstackContainers[asyncId].forEach(id => {
delete callstackMap[id]
})
delete TCPWrapCallstackContainers[asyncId]
}
}

@@ -80,0 +71,0 @@ }).enable()

2

package.json
{
"name": "http-request-context",
"version": "0.2.1",
"version": "0.2.2",
"description": "Store context in http middleware lifecycle.",

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

@@ -44,3 +44,3 @@ /* eslint-disable no-undef */

expressApp.listen(expressPort, function () {
const server = expressApp.listen(expressPort, function () {
console.log(`Express is listening at port ${expressPort}`)

@@ -51,4 +51,6 @@ })

const response = await chai.request(`http://127.0.0.1:${expressPort}`).get('/')
const response = await chai.request(server).get('/')
server.close()
assert.strictEqual(200, response.status)

@@ -77,3 +79,3 @@ assert.strictEqual('value', response.text)

koaApp.listen(koaPort, function () {
const server = koaApp.listen(koaPort, function () {
console.log(`Koa is listening at port ${koaPort}`)

@@ -84,4 +86,6 @@ })

const response = await chai.request(`http://127.0.0.1:${koaPort}`).get('/')
const response = await chai.request(server).get('/')
server.close()
assert.strictEqual(200, response.status)

@@ -88,0 +92,0 @@ assert.strictEqual('value', response.text)

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