Skip to content

Commit

Permalink
Revert back to w/o timeout (#379)
Browse files Browse the repository at this point in the history
* Revert back to w/o timeout

It turns out that `{timeout: 1500}` sets a timeout for the entire request to finish but throws when it is exceeded. This error would need to get caught and then decided upon what to do which complicates things. 

Changed the order so that page.goto can be awaited but still closed after a timeout.

* Update bot.js
  • Loading branch information
terjanq authored Jun 21, 2022
1 parent 4ce6f66 commit cc4450c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions dist/challenge-templates/xss-bot/challenge/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const DOMAIN = process.env.DOMAIN;
if (DOMAIN == undefined) throw 'domain undefined'
const REGISTERED_DOMAIN = process.env.REGISTERED_DOMAIN;
const BLOCK_SUBORIGINS = process.env.BLOCK_SUBORIGINS == "1";
const BOT_TIMEOUT = process.env.BOT_TIMEOUT || 60*1000;

// will only be used if BLOCK_SUBORIGINS is enabled
const PAC_B64 = Buffer.from(`
Expand Down Expand Up @@ -53,9 +54,6 @@ if (BLOCK_SUBORIGINS) {
const page = await context.newPage();
await page.setCookie(cookie);
socket.write(`Loading page ${url}.\n`);
await page.goto(url, {
timeout: 1500 /* add 1.5s margin for network delays */
});
setTimeout(()=>{
try {
context.close();
Expand All @@ -64,7 +62,8 @@ if (BLOCK_SUBORIGINS) {
} catch (err) {
console.log(`err: ${err}`);
}
}, 60000);
}, BOT_TIMEOUT);
await page.goto(url);
}

var server = net.createServer();
Expand Down

0 comments on commit cc4450c

Please sign in to comment.