Skip to content

Commit

Permalink
Fix res.sendFile logging standard write errors
Browse files Browse the repository at this point in the history
fixes #2433
  • Loading branch information
dougwilson committed Nov 23, 2014
1 parent 869ddd7 commit b326ae8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions History.md
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/response.js
Expand Up @@ -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);
}
});
Expand Down
21 changes: 21 additions & 0 deletions test/res.sendFile.js
Expand Up @@ -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'));
Expand Down

0 comments on commit b326ae8

Please sign in to comment.