Wednesday 15 January 2014

jquery - node.js + express API status code 200 but client still pending -


let me node. A very simple and straightforward API has been found in JS and Express which works just fine, but every now and then, jQuery.post calls will be "pending" (and eventually timeout). On the server side, I have monitored the request and the result and it is logging a 200 answer code with the proper data in ~ 40ms. It does not matter how often I refresh the page (the data is static in the call, not on the basis of input), the request is successfully completed on the server, but the client is hung in it. If i node If I restart the Js server script, then all is OK and the normal function is restored to the client.

It went smoothly without restarting for the last 3 days, then I had to repeat it again for about an hour to restart the script, it was now okay for the last 2 hours.

  • Node. Js v0.10.10
  • Express v3.2.6

    Become aware of any information. Thank you.

    Edit - Adding code is a function that is hanging.

      export.getDistinct = function (req, res) {var parameters = {filter: function () {var filter = getParams (req, 'filter'); If (filter) {f = {}; (For Var of the filter) f {key} = {$ in: filter [key]} var search = getParams (req, 'search'); If (search) {for (var key in search) {f [key] = new regExp (assistant. Escapregxp (search [key]), "gi"); }} Return; } Else {// send send send (req, res, {'error': 'no filter specified'}, 500); }} (), Field: function () {var field = getParams (req, 'field'); If (field) returns field; And send (request, ridge, {'error': 'no fields specified'}, 500); } (),}; //console.log(util.inspect (Param, False, Faucet)); Db.results.distinct (params.field, params.filter, function (error, result) {if sending (mistake) (rick, ris, mistake, 500); if (param.field == 'title') {var filtered ({I & Lt; Results.length; ++ i) {if (result [i]. Milan (/ ^ up / ge)) {tcnames.filter (function (TC) {if (tc._id == result [i]) Filtered push (TC);})}} filtered.sort (helper.compare); send (request, ridge, filtered, 200);});} and {send (rik, race, result, 200);}}) ; }   

    and the code used here is the send function: send the function (request, ridge, data, position) {var isJsonp = req.query HasOwnProperty ('callback'); If (! Position) position = 200; If (isJsonp) res.send (req.query ['callback'] + '(' + JSON.stringify (data) + ')', position); And res.send (data, position); }

    Edit just looked at it in httpd.conf and I do not know about it relevant:

      BrowserMatch "Mozilla / 2" Nokia Browser Match "MSIE 4 \ .0b2;" Nokeepalive Downgrade -1 1.0 Force-response -1 1.0 Browser Match "Realplayer 4.0.0" Force-response -1.0 BrowserMatch "Java / 1 \ .0" Force-response -1.0 BrowserMatch "JDK / 1 \ .0" Response -1.0 Browser Match "Microsoft Data Access Internet Publishing Provider" Redirect - Browser Match "MS FrontPage" Redirected - Carefully Browser Match "^ WebDrive" Redirect - Carefully Browser Match "^ WebDAVFS / 1. [0123]" Redirect Browser match "^ gnome-vfs / 1.0" redirection-carefully browser mac "^ XML detective" redirect - browser match with caution "^ Dreamweaver-WebDAV-SCM1" Redirect - Caution    

    So generally these symptoms mean within your request your logic is a branch that ends appropriately by responding to the request Not been done or the Guard Clause return statement drop offs. I think this is an error in your code, and in other cases also:

      sending (mistake) (Rick, Race, mistake, 500);   

    This is a bug, it will send a response but will continue to execute the remaining work, which results in misbehavior. You want:

      if (mistake) {send back (Rick, race, gal, 500); }   

    I think this is your only bug, but this is a good idea for A) Try to keep your argument small and simple enough so that each branch has an HTTP Reaction and a return statement where appropriate and then b) when things are found in large or more branches, whenever you send feedback as a reactionary coding technique return Consider

No comments:

Post a Comment