Skip to content

Commit

Permalink
Merge pull request #198 from catchpoint/pollIntervall
Browse files Browse the repository at this point in the history
Poll interval
  • Loading branch information
claud-io authored Dec 2, 2024
2 parents 0415e87 + e7cf63d commit b3d1815
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lib/consts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const DEFAULT_POLL_VALUE = 60;
const POLL_LOWER_LIMIT = 20;

module.exports = {
DEFAULT_POLL_VALUE,
POLL_LOWER_LIMIT
};
6 changes: 4 additions & 2 deletions lib/webpagetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var http = require("http"),
mapping = require("./mapping"),
qs = require('querystring');

const { DEFAULT_POLL_VALUE, POLL_LOWER_LIMIT} = require("./consts");

var reSpace = /\s/,
reConnectivity =
/^(?:Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom)$/,
Expand Down Expand Up @@ -502,7 +504,7 @@ function runTest(what, options, callback) {

// poll results
if (options.pollResults && !options.dryRun) {
options.pollResults = parseInt(options.pollResults * 1000, 10) || 5000;
options.pollResults = Math.max(POLL_LOWER_LIMIT, options.pollResults || DEFAULT_POLL_VALUE) * 1000;

return api.call(
this,
Expand Down Expand Up @@ -565,7 +567,7 @@ function runTest(what, options, callback) {
function runTestAndWait(what, options, callback) {
delete options.pollResults;

options = Object.assign(options, { pollResults: 13 });
options = Object.assign(options, { pollResults: DEFAULT_POLL_VALUE });

new Promise((resolve) => {
let test = runTest.bind(this, what, options, callback);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webpagetest",
"version": "0.7.5",
"version": "0.7.6",
"description": "WebPageTest API wrapper for NodeJS",
"author": "WebPageTest <github@WebPageTest.com> (http://github.com/WebPageTest)",
"homepage": "http://github.com/WebPageTest/webpagetest-api",
Expand Down

0 comments on commit b3d1815

Please sign in to comment.