Uh oh!
There was an error while loading. Please reload this page.
child_process: fix leak when passing http sockets - #20305
Conversation
After passing an HTTP socket, release its associated resources. Fixes: nodejs#15651
santigimeno
commented
Apr 25, 2018
/cc @gireeshpunathil @nodejs/child_process |
gireeshpunathil
commented
Apr 26, 2018
thanks, will test and let you know. |
gireeshpunathil
commented
Apr 26, 2018
Unfortunately I am unable to see any difference: without the changes: (I am printing only the usedHeap value, because that is the one which matters) with the change: |
santigimeno
commented
Apr 26, 2018
@gireeshpunathil What test code are you using? Thanks |
gireeshpunathil
commented
Apr 26, 2018
#cat s.js consthttp=require('http');const{ fork }=require('child_process');constserver=http.createServer((req,res)=>{constworkerProcess=fork('worker.js',[],{execArgv: []});workerProcess.on('message',(status)=>{switch(status){case'ready':
workerProcess.send({method: req.method,headers: req.headers,path: req.path,httpVersionMajor: req.httpVersionMajor,query: req.query,},res.socket);break;case'done':
res.socket.end();}});});server.listen(8080);setInterval(()=>{console.log(process.memoryUsage().heapUsed)},10000);#cat worker.js consthttp=require('http');process.on('message',(req,socket)=>{constres=newhttp.ServerResponse(req);res._finish=function_finish(){res.emit('prefinish');socket.end();};res.assignSocket(socket);socket.once('finish',()=>{process.send('done',()=>{process.exit(0);});});res.end(process.pid.toString());});process.send('ready'); |
santigimeno
commented
Apr 26, 2018
@gireeshpunathil I'm not seeing that behavior. With the patch, I've been running the code locally for an hour an the P.S. I've been using your code along with the test runner in https://github.com/Reggino/node-issue-15651-test |
gireeshpunathil
commented
Apr 26, 2018
I did further testing, and able to see what you saw:
thanks, LGTM! |
After passing an HTTP socket, release its associated resources. PR-URL: nodejs#20305Fixes: nodejs#15651 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
BridgeAR
commented
Apr 29, 2018
Landed in 511230f 🎉 |
After passing an HTTP socket, release its associated resources.
Fixes: #15651
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes