Fix res.sendFile logging standard write errors

fixes #2433
This commit is contained in:
Douglas Christopher Wilson 2014-11-23 16:53:11 -05:00
parent 869ddd775c
commit b326ae89df
3 changed files with 24 additions and 2 deletions

View File

@ -1,6 +1,7 @@
unreleased
==========
* Fix `res.sendFile` logging standard write errors
* deps: etag@~1.5.1
* deps: proxy-addr@~1.0.4
- deps: ipaddr.js@0.1.5

View File

@ -398,8 +398,8 @@ res.sendFile = function sendFile(path, options, fn) {
if (fn) return fn(err);
if (err && err.code === 'EISDIR') return next();
// next() all but aborted errors
if (err && err.code !== 'ECONNABORT') {
// next() all but write errors
if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') {
next(err);
}
});

View File

@ -69,6 +69,27 @@ describe('res', function(){
.end(done);
})
it('should not error if the client aborts', function (done) {
var cb = after(1, done);
var app = express();
app.use(function (req, res) {
setImmediate(function () {
res.sendFile(path.resolve(fixtures, 'name.txt'));
cb();
});
test.abort();
});
app.use(function (err, req, res, next) {
err.code.should.be.empty;
cb();
});
var test = request(app).get('/');
test.expect(200, cb);
})
describe('with "dotfiles" option', function () {
it('should not serve dotfiles by default', function (done) {
var app = createApp(path.resolve(__dirname, 'fixtures/.name'));