U
U
uSide2013-11-24 19:35:17
Node.js
uSide, 2013-11-24 19:35:17

Request Handlers in ExpressJS

Problem following - there is a request handler with huge logic. Processing lasts from 5 to 20 minutes. If the client closes the connection, express stops executing the handler. How can I tell him not to do it? Those. after the connection is closed by the client, do not stop the handler.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Wolf, 2013-11-24
@uSide

Are you kidding me? Node.js is asynchronous. Fully. Revisit the logic.
You can do it like this, for example:

app.get("/", function(req, res){
 setTimeout(function(result){
  // some logic
  console.log('finished');
 },1000*5);
 res.end('Processing..');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question