Comments (5)
So you cannot access the response time until you've actually responded. I can add an API so you can access the "total elapsed time since the request arrived" which will be sort of like a response time. Would that work?
from response-time.
I'm not sure I would know until I saw it in action. Maybe I should leverage https://developer.mozilla.org/en-US/docs/Navigation_timing on the client instead, but I don't know if that's battling the same race condition.
from response-time.
We could have this module attach a function to the req
object or something. I'm just trying to brainstorm it out with you :) like maybe req.elapsedTime()
or something?
It may also be useful to know that since this module normally does response time, and response time is not actually available to your code until you actually... respond, then there is a work-around with the existing code: build all your response headers and explicitly res.writeHead()
to respond with the headers, then build your view at which point res.getHeader
will have the response time, of course, since you've already started to respond.
from response-time.
Yeah, we can try req.elapsedTime
.
from response-time.
Hi @berkantipek yes, that won't work, which is why this issue is open. The function is called after your view has already been rendered (because rendering the view takes time, which contributes to the response time... you don't know the response time until after you have performed all actions involved in responding, including rendering your view).
from response-time.
Related Issues (11)
- response-time does not contain data about url of request. HOT 1
- Expose X-Response-Time header by default HOT 2
- Different Response Times HOT 3
- Typescript Support HOT 4
- Option to make use of Server Timing header HOT 2
- Add support for request-received middleware HOT 4
- Warning on build for use of eval
- Rename digits to decimals HOT 1
- Add option to disable 'ms' appendix HOT 13
- [RFC] timing only mode HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from response-time.