phantomjs process takes up to 4 seconds to end after phantom.exit()
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
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.
I am experiencing 5 seconds delay with the exit() call.
OS X 10.12.2 PhantomJS 2.1.1
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.
I captured a dtruss trace, it's about 5000 lines long and I failed to spot a likely culprit.
To be clear -- the delay happens only when I have an active network connection.
I can confirm that network connection makes a difference. 😲
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.
Any update on this?
I am also experiencing this. Any new developments.
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!