Skip to content

Commit b3d1815

Browse files
authored
Merge pull request #198 from catchpoint/pollIntervall
Poll interval
2 parents 0415e87 + e7cf63d commit b3d1815

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

lib/consts.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const DEFAULT_POLL_VALUE = 60;
2+
const POLL_LOWER_LIMIT = 20;
3+
4+
module.exports = {
5+
DEFAULT_POLL_VALUE,
6+
POLL_LOWER_LIMIT
7+
};

lib/webpagetest.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ var http = require("http"),
1616
mapping = require("./mapping"),
1717
qs = require('querystring');
1818

19+
const { DEFAULT_POLL_VALUE, POLL_LOWER_LIMIT} = require("./consts");
20+
1921
var reSpace = /\s/,
2022
reConnectivity =
2123
/^(?:Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom)$/,
@@ -502,7 +504,7 @@ function runTest(what, options, callback) {
502504

503505
// poll results
504506
if (options.pollResults && !options.dryRun) {
505-
options.pollResults = parseInt(options.pollResults * 1000, 10) || 5000;
507+
options.pollResults = Math.max(POLL_LOWER_LIMIT, options.pollResults || DEFAULT_POLL_VALUE) * 1000;
506508

507509
return api.call(
508510
this,
@@ -565,7 +567,7 @@ function runTest(what, options, callback) {
565567
function runTestAndWait(what, options, callback) {
566568
delete options.pollResults;
567569

568-
options = Object.assign(options, { pollResults: 13 });
570+
options = Object.assign(options, { pollResults: DEFAULT_POLL_VALUE });
569571

570572
new Promise((resolve) => {
571573
let test = runTest.bind(this, what, options, callback);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpagetest",
3-
"version": "0.7.5",
3+
"version": "0.7.6",
44
"description": "WebPageTest API wrapper for NodeJS",
55
"author": "WebPageTest <[email protected]> (http://github.com/WebPageTest)",
66
"homepage": "http://github.com/WebPageTest/webpagetest-api",

0 commit comments

Comments
 (0)