You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
While there's nothing really for the child to continue doing here, so long as the connection is alive the loop should also be alive.
varcommon=require('../common')varassert=require('assert');varspawn=require('child_process').execFile;varhttp=require('http');varTOTAL_BYTES=100*1024*1024;if(process.argv[2]==='child'){varseen=0;http.get({hostname: '127.0.0.1',port: common.PORT,path: '/',},function(res){console.log('%d\ns',res.statusCode,JSON.stringify(res.headers,null,2));res.on('data',function(chunk){seen+=chunk.length;console.error('chunk received: %d',chunk.length);res.pause();});res.once('end',function(){console.error('ended');});});process.on('exit',function(){// this isn't technically right, but it's more the fact that the loop is// exiting before it shouldconsole.error(seen,TOTAL_BYTES);assert.strictEqual(seen,TOTAL_BYTES);});}else{varbuff=newBuffer(TOTAL_BYTES);varserver=http.createServer(function(req,res){console.log('sending',buff.length);res.end(buff);}).listen(common.PORT,function(){varchild=spawn(process.execPath,[process.argv[1],'child'],{}//{ env: { NODE_DEBUG: 'http net' }});child.on('close',function(code){console.log('closing server');server.close();assert.strictEqual(code,0);});child.stderr.pipe(process.stderr);child.stdout.pipe(process.stdout);});}