Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does GET /bla - - ms - - mean in NodeJs console?

When I go to the page /bla in my NodeJS app, the console prints out

GET /bla - - ms - -

In words (for easier Google searches), dash dash ms dash dash.

What does this mean?

like image 757
CodyBugstein Avatar asked Mar 16 '15 12:03

CodyBugstein


2 Answers

This is the output from morgan, a HTTP request logger middleware for node.js.

It logs all requests, by default, to the console. Depending on your configurations it will display different data from the request.

If you are using the default format (dev), the data displayed is:

:method :url :status :response-time ms - :res[content-length]
like image 108
victorkt Avatar answered Sep 18 '22 23:09

victorkt


According to this thread:

The log line GET / - - ms - - is the dev format saying you never sent a response before Node.js killed the TCP connection for idling too long.

So the problem is a request that wasn't responded by the server - in other words, some middleware along the route never called next(), res.send(), res.end() or any other means to respond.

I realized that this can also occur if the server doesn't handle the client aborting the request (can be easily tested by e.g making the request through a browser and clicking on the X button in the address bar before it's done).

According to the docs, the way to handle that would probably be something like (wasn't tested):

req.on('abort', function (err) {
   if (err)
       console.error(error.message);

   // your code here
});
like image 34
gilad905 Avatar answered Sep 17 '22 23:09

gilad905