Node.js express, timeout "Can\'t set headers after they are sent." -


I have some strange problems with nodes and express.

One of my tasks that handles the request,

  1. Receive the request
  2. Call DB

    Li>

  3. Process the data and pack it on JSON
  4. response.json (JSON)

    Normally it will be all right but if 2 and 3 Because it is the asynchronous that it will respond automatically and there may be an error after the "Sendable" header is sent. When I call 4

    Is anyone else having this problem? Is there any normal way to handle it or I just need to see what the response is ._The header is completely set?

      export.appstimebygroup = function (req, res) {var resp = {}; Var ClientID = Webapi.extractClientId (req); AppTime.getByGroupId (clientId, req.body.groupId, function (error, epistem) {if (error) {handleError (error); resp.returnCode = 0; resp.message = "Something has happened, please contact support ; Res.setHeader ("content type", "app / js"); res.json (resp); return;} resp.returnCode = 1; resp.appstime = appstime; if (res._header) {console. log ("Header Everything Set!"); Return;} res.setHeader ("Content Type", "App / JS"); res.json (resp);}); };   

    And there is asynchronous call in AppTime.getByGroupId.

    OK

      form.on ('error', function (Mistake), problem (multipart-form-data-handling timeout).  

    When this happens, {if (options.defer) {err.status = 400; Next (mistake);} done = True;});

    By default this will res render (400) by default and when the code normally receives the code you want to execute then the problem is.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -