Last active
September 24, 2018 08:46
-
-
Save hmpmarketing/2980df050dc752af65d852eebd88bbae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| await retryTimeout(() => async () => { | |
| await retryGoTo(() => page.goto(url, {timeout:120000,waitUntil: 'networkidle0'}),3, 20000); | |
| await page.waitForSelector('html',{timeout:timeout_value}) | |
| await page.waitForSelector('div.controls', {timeout:5000}); | |
| await page.click('button.action-force',{delay:helpers.getRandomInt(100, 500)}); | |
| await page.waitFor(time*1000); | |
| isPlayed=true; | |
| return isPlayed | |
| },3, 10000); | |
| /////////////////////////////////////////////////////// | |
| const helpers = require("./helpers.js"); | |
| const {TimeoutError} = require('puppeteer/Errors'); | |
| const retryTimeout = (fnc,maxRetries, ms) => new Promise(resolve => { | |
| fnc() | |
| .then(resolve) | |
| .catch((e) => { | |
| if (e instanceof TimeoutError) { | |
| console.log('this is a timeout error') | |
| } | |
| setTimeout((err) => { | |
| helpers.log(bot_id,`Timeout Error, retries left: ${maxRetries}...`); | |
| retryTimeout(fnc,maxRetries - 1, ms).then(resolve); | |
| if (maxRetries <= 0) { | |
| helpers.log(id,'Timeout Error, retries Over') | |
| helpers.end(webdomain, id,'', 'Timeout Error, retries over') | |
| process.exit() | |
| } | |
| }, ms); | |
| }) | |
| }); | |
| module.exports = retryTimeout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment