Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

PhantomJS crashes periodically (every 2 to 4 hours) #13210

Closed
moroccan-dude opened this issue May 8, 2015 · 4 comments
Closed

PhantomJS crashes periodically (every 2 to 4 hours) #13210

moroccan-dude opened this issue May 8, 2015 · 4 comments
Labels

Comments

@moroccan-dude
Copy link

Hi,

I am running Phantomjs v2.0 on a Windows Server 2008 - 64 bits.
We are using it basically to render out html pages to the google crawler in the context of an SPA application.
Phantomjs is installed as a service and monitored to be restarted if it stops.
Turns out, it crashes every 2 to 4 hours depending on something....maybe the number of requests I don't know...I haven't yet to figure that one out.
I have copied below the way phantomjs is started and the snippet from the crash from the windows event viewer. I am aware that the attached dump might not be very helpful. I looked at your instructions to convert the crash dump in a stack trace, but I did not see a Windows version of it. Let me know how I can give you more info. Thank you.

This is how phantomjs is started:
phantomjs.exe --disk-cache=no --local-to-remote-url-access=true myfile.js 4444 http://myapp.com

This is a simplified version of myfile.js
var renderHtml = function(url, cb) {

var page = require('webpage').create();
page.settings.loadImages = false;
page.settings.localToRemoteUrlAccessEnabled = true;
page.onCallback = function(data) {
cb(page.content);
    page.close();
};

page.onInitialized = function() {
   page.evaluate(function() {
        setTimeout(function() {
            console.log('CONSOLE: onInitialized timeout');
        }, 45000);
    });
};

page.open(url);

};

server.listen(port, function (request, response) {

var url = computeTheRedirectingURL();
console.log('INCOMING      : ' + request.url);
console.log('REDIRECTED TO : ' + url);

renderHtml(url, function(html) {
    response.statusCode = 200;
    response.write(html);
    response.close();
});

});

crash dump - phantomjs 2 - windows:
(XXXX below are just placeholders that I replaced)

  • Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"
  • System:
    • Provider Name="Application Error"
    • EventID Qualifiers="0" 1000
    • Level 2
    • Task 100
    • Keywords 0x80000000000000
    • TimeCreated SystemTime="2015-05-08T08:46:17.000000000Z"
    • EventRecordID 77170
    • Channel Application
    • Computer XXXXXXXX

  • EventData
    • Data phantomjs.exe
    • Data 2.0.0.0
    • Data 54d21d63
    • Data phantomjs.exe
    • Data 2.0.0.0
    • Data 54d21d63
    • Data c0000005
    • Data 00aee303
    • Data 17a0
    • Data 01d0893d24155ab0
    • Data XXXXX\phantomjs-2.0.0-windows\bin\phantomjs.exe
    • Data XXXXX\phantomjs-2.0.0-windows\bin\phantomjs.exe
    • Data b06a02d0-f55e-11e4-80f8-0af9c7eba8e4
@moroccan-dude
Copy link
Author

Anyone else having the same issue?

@moroccan-dude
Copy link
Author

Update:

  • When setting page.settings.loadImages to false (as above) --> Phantomjs crashes as explained above...Basically I noticed that the memory is up the roof rather quickly. It leaks badly and in 2-4 hours the phantom process reaches 1GB...then it simply crashes.
  • When I tried setting page.settings.loadImages to true --> Phantomjs does not crash anymore, and works fine anywhere between 24 to 48 hours. After this time, it simply does not respond anymore. It hangs. Running a netstat -aon | find /i "4444", I can see that there is still something listening on that port. But it just refuses to respond. The listener is in a 'dead' mode...

I also tried adding this property page.settings.clearMemoryCaches and setting it to true or false does not seem to significantly impact the behavior described above.
Here is a dmp file in the case of:
page.settings.loadImages = true
page.settings.clearMemoryCaches = false
https://www.dropbox.com/s/wqrbh9rp3k7vcab/phantomjs.exe_150526_163423.dmp?dl=0

I have read through the different posts and hanging/crashing does not seem to be that uncommon in phantomjs 2.0...unfortunately, I did not see any answer to the problem til now.

Any idea guys,

@essandess
Copy link

We also see issues like this downloading jillions of web pages in isp-data-pollution. We also set:

dcap['phantomjs.page.settings.loadImages'] = ( 'false' )
dcap['phantomjs.page.settings.clearMemoryCaches'] = ('true')

I've wrapped all the calls to phantomjs methods with timeouts that should return control to the script if phantomjs hangs, but there are remaining issues.

See essandess/isp-data-pollution#26 .

@stale stale bot added the stale label Dec 26, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

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 stale bot closed this as completed Dec 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants