zhujun24 / http-request-context Goto Github PK
View Code? Open in Web Editor NEWStore context in http request's lifecycle.
License: MIT License
Store context in http request's lifecycle.
License: MIT License
环境
app: https://github.com/appsecco/dvna
node: v12.16.1
在dvna上,如果http-request-context在passport中间件之前使用上下文将会丢失,从当前executionAsyncId往上查找,找不到rootId
看了cls_hooked 和express-http-context 的issues都存在这个问题,
如果将http-request-context 在passport中间件之后使用,则可以获取上下文
it ends with
TypeError: Cannot set property 'data' of undefined
at middleware (/path/to/node_modules/http-request-context/index.js:89:29)
if either removeAfterFinish or removeAfterClose is set to true. the first request
and I guess if the connection is kept alive longer than options.alive, it will be out of order, either...
acoording to the document and your zhihu zhuanlan,
The TCPWRAP is the new connection from the client. When a new connection is made, the TCPWrap instance is immediately constructed.
i guess that connection and request might not be a 1:1 map.
emmm... but not sure. because i'm using it with koa-convert.back for koav1 compatibility. haven't dig deeply into async_hooks internal yet.
When I run my tests with jest three of them returns:
Jest has detected the following 3 open handles potentially keeping Jest from exiting
Pointing this part of the code:
28 | .use(express.json({ limit: '100mb' }))
29 | .use(express.urlencoded({ limit: '100mb', extended: true }))
30 | .use(httpContext.middleware({
| ^
31 | removeAfterClose: true,
32 | removeAfterFinish: true,
33 | }))
at interval (node_modules/http-request-context/index.js:22:3)
at Object.middleware (node_modules/http-request-context/index.js:119:5)
at new WebApp (src/infra/web/index.ts:30:24)
Any ideia what am I doing wrong? Already tried to move the middleware to other parts of the express instantiation but the problem remains.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.