node-phantom icon indicating copy to clipboard operation
node-phantom copied to clipboard

When calling exit(), added call to phantom.kill()

Open ryanone opened this issue 12 years ago • 12 comments

Calling exit() doesn't terminate the spawned process. So I added a call to phantom.kill() to do the trick.

Fixes #24

ryanone avatar Dec 20 '12 20:12 ryanone

oh thank god. that explains why phantom never dies for me.

AndrewRayCode avatar Dec 29 '12 01:12 AndrewRayCode

This does not work for me. Normally all PhantomJS instances exit correctly for me, but if I include this they stop exiting. Which platform are you on?

alexscheelmeyer avatar Jan 11 '13 09:01 alexscheelmeyer

Thanks for responding, Alex.

I'm on RHEL6.

@DelvarWorld - How about you?

ryanone avatar Jan 11 '13 20:01 ryanone

CentOS 6(RHEL 6) here -- Same issue. But, I assumed it was because I haven't figured out how to add a timeout to the phantom object.

ndrut avatar Jan 16 '13 18:01 ndrut

I see this, too: Phantom never dies. On OS X, using 1.8.1.

sandinmyjoints avatar Jan 23 '13 17:01 sandinmyjoints

Also using 1.8.1 on osx

kaareal avatar Mar 26 '13 11:03 kaareal

This line fixes phantom process not exiting for me

  • Arch Linux Kernel 3.8.4
  • PhantomJS 1.9.0
  • Node.js 0.10.2

eddloschi avatar Apr 03 '13 18:04 eddloschi

I think one need to wait for the kill event to be send. I resolved this by waiting a bit before exiting the script.

kaareal avatar Apr 24 '13 14:04 kaareal

having the same problem on osx 10.7.5 phantomjs 1.9.0 Node 0.8.10

The instances are draining a lot of cpu as well from what I can see in top -o cpu

Its the bridge.js that has started them from what I can see with ps aux | grep phantom

potmo avatar Jul 04 '13 12:07 potmo

The fix doesn't work for me. I think I get a script error in phantom that crashes phantom silently. The phantom-process is never killed

potmo avatar Jul 04 '13 12:07 potmo

Whew, just spent hours wondering why I was spawning off phantomjs zombie processes. Fix works for me - I can't modify the node-phantom code so I'm working around it by using:

ph.exit();
ph._phantom.kill('SIGTERM');

AlexGilleran avatar Sep 18 '13 04:09 AlexGilleran

shouldn't the right place to put this be line 141: ?

case 'phantomExited':
                            request(socket,[0,'exitAck']);
                            server.close();
                            io.set('client store expiration', 0);
                            cmds[cmdId].cb();
                            phantom.kill('SIGTERM');
                            delete cmds[cmdId];
                            break;

thisispete avatar Jul 01 '15 04:07 thisispete