1'use strict'; 2const common = require('../common'); 3 4// This test ensures that Node.js doesn't crash with an AssertionError at 5// `ServerResponse.resOnFinish` because of an out-of-order 'finish' bug in 6// pipelining. 7// https://github.com/nodejs/node/issues/2639 8 9const http = require('http'); 10const net = require('net'); 11 12const COUNT = 10; 13 14const server = http 15 .createServer( 16 common.mustCall((req, res) => { 17 // Close the server, we have only one TCP connection anyway 18 server.close(); 19 res.writeHead(200); 20 res.write('data'); 21 22 setTimeout(function() { 23 res.end(); 24 }, (Math.random() * 100) | 0); 25 }, COUNT) 26 ) 27 .listen(0, function() { 28 const s = net.connect(this.address().port); 29 30 const big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT); 31 32 s.write(big); 33 s.resume(); 34 }); 35