phantomjs icon indicating copy to clipboard operation
phantomjs copied to clipboard

phantomjs process takes up to 4 seconds to end after phantom.exit()

Open dadza opened this issue 10 years ago • 10 comments

I'm using PhantomJS 2.1.1 under OS X El Capitan (10.11.3). The process takes about 3-4 for seconds to end after phantom.exit() is being called. This happens most of the time, but not always.

I tested with the trivial Hello world example from https://github.com/ariya/phantomjs/blob/master/examples/hello.js

The timestamps look like this:

lchirita@MacBook-Pro-Lucian:~/tmp/phantomjs$ (phantomjs hello.js && echo done ) |ts "%H:%M:%.S"
16:08:33.748764 Hello, world!
16:08:37.579262 done

Notice the 4 second delay between the console.log line, which is right before phantom.exit(), and the "echo done" line which is written after the process has ended.

2.0.0 is fine, the process ends almost immediately after exit(). Like this:

lchirita@MacBook-Pro-Lucian:~/tmp/phantomjs$ (phantomjs hello.js && echo done ) |ts "%H:%M:%.S"
16:11:43.461184 Hello, world!
16:11:43.481345 done

dadza avatar Feb 22 '16 14:02 dadza

I have the same behaviour in Windows 7 and PhantomJS 2.1.1. Maybe even longer than 4 seconds.

If I remember correctly, PhantonJS 1.9.x didn't have the delay.

jmullo avatar Jun 03 '16 11:06 jmullo

I am experiencing 5 seconds delay with the exit() call.

OS X 10.12.2 PhantomJS 2.1.1

raido avatar Dec 28 '16 11:12 raido

I'm seeing this as well on macOS Sierra with PhantomJS 2.1.1

$ phantomjs -v
2.1.1

$ wget https://github.com/ariya/phantomjs/raw/master/examples/rasterize.js
# ... snip ...
2017-03-16 11:21:56 (28.9 MB/s) - ‘rasterize.js’ saved [2241/2241]

$ echo "<html><title>Hello</title><body>World</body></html>" > test.html

$ time phantomjs rasterize.js test.html test.pdf
phantomjs rasterize.js test.html test.pdf  0.60s user 0.29s system 17% cpu 5.056 total

$ # turn wifi off

$ time phantomjs rasterize.js test.html test.pdf
phantomjs rasterize.js test.html test.pdf  0.65s user 0.26s system 91% cpu 0.988 total

$ # turn wifi back on

$ time phantomjs rasterize.js test.html test.pdf
phantomjs rasterize.js test.html test.pdf  0.65s user 0.29s system 18% cpu 5.182 total

Note how the first and last tests take a bit more than 5 seconds, while the second one takes about 1 second.

aaugustin avatar Mar 16 '17 10:03 aaugustin

I captured a dtruss trace, it's about 5000 lines long and I failed to spot a likely culprit.

aaugustin avatar Mar 16 '17 10:03 aaugustin

To be clear -- the delay happens only when I have an active network connection.

aaugustin avatar Mar 16 '17 10:03 aaugustin

I can confirm that network connection makes a difference. 😲

raido avatar Mar 16 '17 11:03 raido

At first I suspected a DNS resolution timeout but I failed to confirm this guess: every domain name phantomjs would have a reason to connect to resolves instantly on my machine.

aaugustin avatar Mar 16 '17 11:03 aaugustin

Any update on this?

sajal50 avatar Jun 06 '17 23:06 sajal50

I am also experiencing this. Any new developments.

computermathman avatar Jul 18 '17 15:07 computermathman

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

stale[bot] avatar Dec 29 '19 08:12 stale[bot]