Giter Site home page Giter Site logo

Comments (5)

dougwilson avatar dougwilson commented on April 19, 2024

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.

kevinSuttle avatar kevinSuttle commented on April 19, 2024

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.

dougwilson avatar dougwilson commented on April 19, 2024

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.

kevinSuttle avatar kevinSuttle commented on April 19, 2024

Yeah, we can try req.elapsedTime.

from response-time.

dougwilson avatar dougwilson commented on April 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.