Skip to content

Commit 104448b

Browse files
committed
Force overall timeout of 10s and resource timeout of 5s
1 parent 0301236 commit 104448b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Engine/Convert/Resources/PhantomJs-rasterize.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ system = require('system'),
3232
address, output, size;
3333

3434
// Reference: https://stackoverflow.com/questions/16854788/phantomjs-webpage-timeout
35-
// Add resource timeout to avoid a permanent hang.
36-
page.settings.resourceTimeout = 10000; // ms
35+
// Add resource timeout to avoid a permanent hang. It applies to each individual resource.
36+
page.settings.resourceTimeout = 5000; // ms
3737
page.onResourceTimeout = function(e) {
3838
console.log(e.errorCode); // it'll probably be 408
3939
console.log(e.errorString); // it'll probably be 'Network timeout on resource'
@@ -74,6 +74,10 @@ if (system.args.length < 3 || system.args.length > 5) {
7474
page.zoomFactor = system.args[4];
7575
}
7676
page.open(address, function (status) {
77+
window.setTimeout(function () {
78+
console.log("Page took too long to load");
79+
phantom.exit(1);
80+
}, 10000);
7781
if (status !== 'success') {
7882
console.log('Unable to load the address!');
7983
phantom.exit();

0 commit comments

Comments
 (0)