Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close/aborted requests should log as http 444 #1565

Closed
3 tasks done
DonutEspresso opened this issue Nov 15, 2017 · 1 comment
Closed
3 tasks done

Close/aborted requests should log as http 444 #1565

DonutEspresso opened this issue Nov 15, 2017 · 1 comment

Comments

@DonutEspresso
Copy link
Member

  • Used appropriate template for the issue type
  • Searched both open and closed issues for duplicates of this issue
  • Title adequately and concisely reflects the feature or the bug

Bug Report

When a request is closed by the client or aborted, restify doesn't change the default status code which is 200. This trickles through the audit log as well as the metrics plugin. Technically a response was never written, but if you are looking at aggregate metrics this can be quite misleading.

Restify Version

All

Node.js Version

All

Expected behaviour

I would expect an http 444 for req.on('close'). This seems applicable for req.on('abort') as well, but open to other status codes.

Actual behaviour

Restify leaves the default status code of 200.

Repro case

const restify = require('restify');
const log = require('bunyan').createLogger({ name: 'foo '});
const server = restify.createServer({
    name: 'foo'
});

server.on('after', restify.plugins.auditLogger({
    server: server, // this ensures `audit` event is called
    event: 'after',
    log: log.child({
        component: 'audit'
    })
}));

server.get('/', function(req, res, next) {
    setTimeout(function() {
        return next();
    }, 3000);
});

server.listen(3000);

Start the process, then curl and ctrl-c the request. Wait for timeout to expire. See 200 in the audit logs.

Cause

These event listeners should probably set the status code as appropriate:
https://github.com/restify/node-restify/blob/master/lib/server.js#L1012

@hekike
Copy link
Member

hekike commented Mar 30, 2018

I think we can close this.

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

No branches or pull requests

2 participants