http-request-context
Advanced tools
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() |
{ | ||
"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) |
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
13970
235