diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js index 92c1e45dd25d01..17e9db976c099a 100644 --- a/test/parallel/test-http-remove-header-stays-removed.js +++ b/test/parallel/test-http-remove-header-stays-removed.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const http = require('http'); @@ -54,13 +54,14 @@ server.listen(0, function() { res.setEncoding('ascii'); res.on('data', function(chunk) { response += chunk; + if (response === 'beep boop\n') { + setTimeout(function() { + // The socket should be closed immediately, with no keep-alive, because + // no content-length or transfer-encoding are used: + assert.strictEqual(res.socket.closed, true); + server.close(); + }, common.platformTimeout(15)); + } }); - - setTimeout(function() { - // The socket should be closed immediately, with no keep-alive, because - // no content-length or transfer-encoding are used: - assert.strictEqual(res.socket.closed, true); - server.close(); - }, 10); }); });