Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 5e9de5d · Browse files · 3 files+19 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+19 added−10 removed

  • tests:+17 added−9 removed
  • other:+2 added−1 removed

3 files+19 added−10 removed

modified:lib/response.js+1 added-1 removed
498 unmodified lines
499 if (done) return done(err);500 if (err && err.code === 'EISDIR') return next();501502 // next() all but write errors503 if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') {503 if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') {504 next(err);505 }506 });507};
630 unmodified lines
modified:test/res.sendFile.js+17 added-9 removed
94 unmodified lines
95 .end(done);96 })9798 it('should not error if the client aborts', function (done) {99 var cb = after(1, done);99 var app = express();100 var cb = after(2, done)101 var error = null102103 app.use(function (req, res) {104 setImmediate(function () {105 res.sendFile(path.resolve(fixtures, 'name.txt'));106 server.close(cb)107 setTimeout(function () {108 cb(error)109 }, 10)106 });110 })111 test.abort();112 });113114 app.use(function (err, req, res, next) {111 err.code.should.be.empty()112 cb();115 error = err116 next(err)117 });118119 var server = app.listen()120 var test = request(server).get('/')117 test.expect(200, cb);121 test.end()122 })123124 describe('with "cacheControl" option', function () {125 it('should enable cacheControl by default', function (done) {
505 unmodified lines
631 .expect(200, '20%', done);632 });633634 it('should not error if the client aborts', function (done) {631 var cb = after(1, done);635 var app = express();636 var cb = after(2, done)637 var error = null638639 app.use(function (req, res) {640 setImmediate(function () {641 res.sendfile(path.resolve(fixtures, 'name.txt'));642 server.close(cb)643 setTimeout(function () {644 cb(error)645 }, 10)646 });647 test.abort();648 });649650 app.use(function (err, req, res, next) {643 err.code.should.be.empty()644 cb();651 error = err652 next(err)653 });654655 var server = app.listen()656 var test = request(server).get('/')649 test.expect(200, cb);657 test.end()658 })659660 describe('with an absolute path', function(){661 it('should transfer the file', function(done){
142 unmodified lines
modified:History.md+1 added
1unreleased2==========34 * Fix issue where `"Request aborted"` may be logged in `res.sendfile`5 * Fix JSDoc for `Router` constructor6 * deps: body-parser@1.18.37 - Fix deprecation warnings on Node.js 10+8 - Fix stack trace for strict json parse error
3413 unmodified lines