Node JS gets gets stuck after Error: ENOENT

611 views
Skip to first unread message

jeenson ephraim

unread,
Jun 4, 2014, 6:54:26 AM6/4/14
to nod...@googlegroups.com

My application uses node.js (10.28) and express (3.4.7) the server.js is like this


var express = require('express'),
config = require('./services/resource/config.js'),
routeprocess = require('./services/routeprocess/routeprocess.js'),
socketevent = require('./socketevent'),
cluster = require('cluster'),
RedisStore = require('socket.io/lib/stores/redis')
redis  = require('socket.io/node_modules/redis')
numCPUs = require('os').cpus().length;
logger = require('./services/logger/logger.js');
var channels=['XXXXXX','YYYYYY','ZZZZZZZZZZ'];

app = express();
app.use(express.compress());
app.use(express.favicon());
app.use(app.router);

app.use(function(req, res){
   res.sendfile(__dirname + '/web/'+ req.url );
});

app.use(function(err,req,res,next) {
    console.log(err);
});

app.get('/', function(req, res){
  res.sendfile(__dirname + '/web/'+ 'index.html' );
});

// couple of REST Calls
app.all('/rest/summary/:code?', function (req, res) {        
   routeprocess.onStoreGraphSummary(req, res, req.params.storeCode);
});

app.all('/rest/offerdetails/:offerNos?', function (req, res) {      
   routeprocess.onOfferDetails(req, res, req.params.offerNos);
});

app.use(express.static(__dirname + '/web',{ maxAge: 2592000000 }));
// Below this we have the forking / redisstore , socket etc 

The issue is that once the server starts and runs for a few minutes , we start getting a lot of Error: ENOENT

something like this


Error: ENOENT, stat '/home/auto/xxxx/appp/4Jun/8180/web//dashsummary'
[2014-06-04 04:31:52.130] [INFO] console - { [Error: ENOENT, stat '/home/auto/xxxx/appp/4Jun/8180/web//dashsummary']
  errno: 34,
  code: 'ENOENT',
  path: '/home/auto/xxxx/appp/4Jun/8180/web//dashsummary',
  status: 404 }


/dashsummary is a valid link which is mentioned in my AngularJS application in my routeprovider



$routeProvider .when('/dashsummary', { controller: 'DashController', templateUrl: 'view/modules/dashsummary.html' })


These Error: ENOENT happen so many times and I feel the NodeJS server is completely stuck at this

Any help is appreciated

Thanks



Forrest Norvell

unread,
Jun 4, 2014, 12:58:04 PM6/4/14
to nod...@googlegroups.com

It looks like you don’t have an explicit route handler in Express for /dashsummary, so when Angular is making requests to that on the browser side, it’s falling through to this middleware:

app.use(function(req, res){
    res.sendfile(__dirname + '/web/'+ req.url );
});

which would explain the /web//dashsummary lstat entries (with the double slash). Just because you’ve defined a route on the Angular side doesn’t mean that Express is going to be able to handle it!

Also, you should probably add an Express error handler so that something is done with those erroneous requests. Express offers one (as a plugin, if you’re using Express 4), or you can write your own fairly simply.

F



--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/c69a3b23-4daf-4b25-b2c6-5c80482d0ac0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages