diff --git a/.labrc.js b/.labrc.js deleted file mode 100644 index e26ff2976..000000000 --- a/.labrc.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -const Somever = require('@hapi/somever'); - -module.exports = { - 'coverage-predicates': { - allowsStoppedReq: Somever.match(process.version, '<18.19.0'), - } -}; diff --git a/lib/core.js b/lib/core.js index 43329536f..202f6dbe0 100755 --- a/lib/core.js +++ b/lib/core.js @@ -506,12 +506,6 @@ exports = module.exports = internals.Core = class { return (req, res) => { - // $lab:coverage:off$ $not:allowsStoppedReq$ - if (this.phase === 'stopping') { - return req.destroy(); - } - // $lab:coverage:on$ $not:allowsStoppedReq$ - // Create request const request = Request.generate(this.root, req, res, options); diff --git a/test/core.js b/test/core.js index f2bde9f32..3730254a0 100755 --- a/test/core.js +++ b/test/core.js @@ -19,6 +19,7 @@ const Hapi = require('..'); const Hoek = require('@hapi/hoek'); const Inert = require('@hapi/inert'); const Lab = require('@hapi/lab'); +const Teamwork = require('@hapi/teamwork'); const Vision = require('@hapi/vision'); const Wreck = require('@hapi/wreck'); @@ -938,6 +939,26 @@ describe('Core', () => { expect(server._core.started).to.equal(false); }); + it('allows incoming requests during the stopping phase', async () => { + + const team = new Teamwork.Team(); + + const server = Hapi.server(); + server.route({ method: 'GET', path: '/', handler: () => 'ok' }); + server.ext('onPreStop', () => team.work); + + await server.start(); + const stop = server.stop(); + const { res, payload } = await Wreck.get(`http://localhost:${server.info.port}`); + + team.attend(); // Allow server to finalize stop + await stop; + + expect(res.headers.connection).to.equal('close'); + expect(payload.toString()).to.equal('ok'); + expect(server._core.started).to.equal(false); + }); + it('finishes in-progress requests and ends connection', async () => { let stop;