diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61ed0beb6..4030abb7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: - 10.x - 12.x - 14.x + - 16.x runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v2 diff --git a/lib/plugins/bodyReader.js b/lib/plugins/bodyReader.js index a71cfb0be..82c9d1016 100644 --- a/lib/plugins/bodyReader.js +++ b/lib/plugins/bodyReader.js @@ -186,7 +186,7 @@ function bodyReader(options) { // add 'close and 'aborted' event handlers so that requests (and their // corresponding memory) don't leak if client stops sending data half // way through a POST request - req.once('close', next); + req.socket.once('close', next); req.once('aborted', next); req.resume(); } diff --git a/test/plugins/static.test.js b/test/plugins/static.test.js index b80bff32b..c98ec1b2e 100644 --- a/test/plugins/static.test.js +++ b/test/plugins/static.test.js @@ -350,11 +350,14 @@ describe('static resource plugin', function() { directory: TMP_PATH }); + var socket = new net.Socket(); SERVER.get('/index.html', function(req, res, next) { // closed before serve - serve(req, res, function(nextRoute) { - assert.strictEqual(nextRoute, false); - done(); + socket.on('end', () => { + serve(req, res, function(nextRoute) { + assert.strictEqual(nextRoute, false); + done(); + }); }); }); SERVER.on('after', function(req, res, route, afterErr) { @@ -362,7 +365,6 @@ describe('static resource plugin', function() { done(); }); - var socket = new net.Socket(); socket.connect({ host: '127.0.0.1', port: PORT }, function() { socket.write(RAW_REQUEST, 'utf-8', function(err2, data) { assert.ifError(err2);