Skip to content

Instantly share code, notes, and snippets.

@kdzwinel

kdzwinel/bad.js Secret

Created January 17, 2019 14:11
Show Gist options
  • Save kdzwinel/d853006b0934c9ae3b5852eb964f292c to your computer and use it in GitHub Desktop.
Save kdzwinel/d853006b0934c9ae3b5852eb964f292c to your computer and use it in GitHub Desktop.
bad.js will fail, good.js will work in 1.11.0
const puppeteer = require('puppeteer');
async function main() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// disabling request interception allows page to load
await page.setRequestInterception(true);
page.on("request", request => request.continue());
try {
await page.goto('http://127.0.0.1:8080/test_page.html', { timeout: 5000, waitUntil: 'load' });
// 🐞this never happens in pptr > 1.6.2 (last tested was 1.11.0)
console.log('success ✅')
} catch (e) {
console.log('timeout 🔴');
}
await browser.close();
}
main();
const puppeteer = require('puppeteer');
async function main() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const cdpClient = page._client; // reusing same session to be as close to puppeteer implementation as possible
await cdpClient.send('Network.setCacheDisabled', {cacheDisabled: true});
await cdpClient.send('Network.setRequestInterception', {patterns: [{urlPattern: '*'}]});
cdpClient.on('Network.requestIntercepted', request => {
cdpClient.send('Network.continueInterceptedRequest', {interceptionId: request.interceptionId});
});
try {
await page.goto('http://127.0.0.1:8080/test_page.html', { timeout: 5000, waitUntil: 'load' });
console.log('success ✅')
} catch (e) {
console.log('timeout 🔴');
}
await browser.close();
}
main();
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
document.write('<script src="http://de.ioam.de/tx.io?mg=no&amp;st=toi&amp;cp=%2Ftest%2Froot&amp;oc=%2Froot&amp;sv=in&amp;pt=CP&amp;ps=lin&amp;er=N22&amp;rf=&amp;r2=&amp;ur=example.com%3A8080&amp;xy=1440x900x24&amp;lo=ES%2Fxxx&amp;cb=0012&amp;i2=0012a7493b1041c925c360c56&amp;ep=1569196621&amp;vr=412&amp;id=xi82n4&amp;i3=nocookie&amp;n1=3&amp;dntt=0&amp;lt=1547045974863&amp;ev=&amp;cs=z9zs2b&amp;mo=1">' + '</scr' + 'ipt>');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment