Skip to content
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.

Aborted requests show status code 200 in response event #729

Closed
clcpolevaulter opened this issue Oct 11, 2018 · 5 comments
Closed

Aborted requests show status code 200 in response event #729

clcpolevaulter opened this issue Oct 11, 2018 · 5 comments

Comments

@clcpolevaulter
Copy link

Notice that the response event below has a statusCode of 200 even though the request was aborted by the client. When logging this event, the status code becomes misleading when troubleshooting. Is there a way to set the status code to 499 instead? This seems related to hapijs/hapi#3561.

{
  "event": "response",
  "timestamp": 1539281741125,
  "id": "1539281741125:localhost:70560:jn4wlokx:10000",
  "instance": "http://localhost:8083",
  "method": "get",
  "path": "/version",
  "query": {},
  "responseTime": 4022,
  "statusCode": 200,
  "pid": 70560,
  "httpVersion": "1.1",
  "source": {
    "remoteAddress": "127.0.0.1",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
  },
  "route": "/version",
  "log": [
    {
      "request": "1539281741125:localhost:70560:jn4wlokx:10000",
      "timestamp": 1539281742112,
      "tags": [
        "request",
        "error",
        "abort"
      ],
      "channel": "internal"
    },
    {
      "request": "1539281741125:localhost:70560:jn4wlokx:10000",
      "timestamp": 1539281745146,
      "tags": [
        "handler",
        "error"
      ],
      "error": {
        "data": "adam",
        "isBoom": true,
        "isServer": true,
        "output": {
          "statusCode": 500,
          "payload": {
            "statusCode": 500,
            "error": "Internal Server Error",
            "message": "An internal server error occurred"
          },
          "headers": {}
        },
        "isDeveloperError": true
      },
      "channel": "internal"
    }
  ],
  "config": {}
}
@clcpolevaulter
Copy link
Author

Also, notice the actual request failed even though the status code is showing as 200. 😕

@clcpolevaulter
Copy link
Author

Route handler looks like:

{
    config: {
        auth: false,
        handler() {
            return new Promise(function (resolve, reject) {
                setTimeout(function () {
                    reject(new Error('adam'));
                }, 4000);
            });
        }
    },
    method: 'GET',
    path: '/version'
}

I cancel the request from the browser before it finishes to produce the error.

@hhowe29
Copy link

hhowe29 commented Oct 11, 2018

this line in response.js seems suspicious.

Scratch that. The 200 appears to be emanating from node's ServerResponse

@clcpolevaulter
Copy link
Author

@hueniverse ::

I see you tackled hapijs/hapi#3561. This seems related. Thoughts on if this is a bug or expected behavior?

@hueniverse
Copy link

@clcpolevaulter I am not sure what to do about this yet, but go ahead and open an issue on hapi.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants