Permalink
Browse files

Fix issue where "Request aborted" may be logged in res.sendfile

  • Loading branch information...
dougwilson committed Sep 20, 2018
1 parent 5e9de5d commit 3d10279826f59bf68e28995ce423f7bc4d2f11cf
Showing with 19 additions and 10 deletions.
  1. +1 −0 History.md
  2. +1 −1 lib/response.js
  3. +17 −9 test/res.sendFile.js
View
@@ -1,6 +1,7 @@
unreleased
==========
* Fix issue where `"Request aborted"` may be logged in `res.sendfile`
* Fix JSDoc for `Router` constructor
* deps: body-parser@1.18.3
- Fix deprecation warnings on Node.js 10+
View
@@ -500,7 +500,7 @@ res.sendfile = function (path, options, callback) {
if (err && err.code === 'EISDIR') return next();
// next() all but write errors
if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') {
if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') {
next(err);
}
});
View
@@ -96,25 +96,29 @@ describe('res', function(){
})
it('should not error if the client aborts', function (done) {
var cb = after(1, done);
var app = express();
var cb = after(2, done)
var error = null
app.use(function (req, res) {
setImmediate(function () {
res.sendFile(path.resolve(fixtures, 'name.txt'));
server.close(cb)
});
setTimeout(function () {
cb(error)
}, 10)
})
test.abort();
});
app.use(function (err, req, res, next) {
err.code.should.be.empty()
cb();
error = err
next(err)
});
var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
test.end()
})
describe('with "cacheControl" option', function () {
@@ -628,25 +632,29 @@ describe('res', function(){
});
it('should not error if the client aborts', function (done) {
var cb = after(1, done);
var app = express();
var cb = after(2, done)
var error = null
app.use(function (req, res) {
setImmediate(function () {
res.sendfile(path.resolve(fixtures, 'name.txt'));
server.close(cb)
setTimeout(function () {
cb(error)
}, 10)
});
test.abort();
});
app.use(function (err, req, res, next) {
err.code.should.be.empty()
cb();
error = err
next(err)
});
var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
test.end()
})
describe('with an absolute path', function(){

0 comments on commit 3d10279

Please sign in to comment.