Coder Social home page Coder Social logo

Extending the timeout about timeout HOT 7 OPEN

expressjs avatar expressjs commented on July 30, 2024
Extending the timeout

from timeout.

Comments (7)

dougwilson avatar dougwilson commented on July 30, 2024 3

haha, I thought of that solution as well, and oops, forgot to mention it above. Yea, that is a good solution; I'll definitely work to implement, but not 100% sure if it'll be today, so please feel free to work on that implementation :) AFAIK, req.setTimeout method already exists, so will probably need to refactor some stuff not to shadow that method.

from timeout.

dougwilson avatar dougwilson commented on July 30, 2024

Hi @drmrbrewer that is defiantly an interesting use-case. Without understanding more about how your code is set up, it's hard to really say if it's a bad thing to do ;)

The idea is interesting enough I thought maybe to just add it, but since this module uses a setTimeout object under the hood, that object does not provide any way to ether (a) extend the timeout or (b) get the elapsed time it has seen, which certainly would make implement this difficult.

from timeout.

drmrbrewer avatar drmrbrewer commented on July 30, 2024

Thanks for considering. It would even be useful just to cancel the existing setTimeout() (which is I assume what is presently possible via req.clearTimeout()) and re-start a new setTimeout() using a different timeout value to the one used originally. That way, when a new request comes in that I know will need a little more time, I can (before I've started really processing the request) just set up a new (longer) timeout.

from timeout.

rohithkd avatar rohithkd commented on July 30, 2024

@dougwilson any update on that? If connect-timeout can override the default behavior, it would be very helpful.

from timeout.

dougwilson avatar dougwilson commented on July 30, 2024

I did a tiny bit of work on this a while back, but I think there was some complications and I shelved the work and forgot about it.

from timeout.

UziTech avatar UziTech commented on July 30, 2024

This would help me out as well. I created PR #34 that adds 3 methods.

req.setTimeout(delay): reset the timeout and start from now
req.addTimeout(delay): add to the current timeout
req.timeoutLeft(): get the amount of milliseconds left (0 after timedout)

from timeout.

JamesMGreene avatar JamesMGreene commented on July 30, 2024

See express-timeout-handler alternative implementation with the ability to override the timeout. 👍🏻

from timeout.

Related Issues (20)

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.