Skip to content

Commit

Permalink
even more debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
catdad committed Feb 19, 2024
1 parent 6e75a87 commit a16c5e4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/connect-puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ module.exports = ({ rendererInterval = 5, rendererTimeout = 2000 }) => {
let browser, stopped = false;

const stopBrowser = async () => {
console.log('a');
if (browser) {
await browser.disconnect();
browser = null;
}
console.log('b');
};

const start = async ({ browserWSEndpoint }) => {
Expand All @@ -24,13 +26,18 @@ module.exports = ({ rendererInterval = 5, rendererTimeout = 2000 }) => {
await stopBrowser();
}

console.log(1);

// defaultViewport: null makes sure that puppeteer does not automatically override the viewport
// and allows the viewport to match the window size
// https://stackoverflow.com/questions/52553311/how-to-set-max-viewport-in-puppeteer
browser = await puppeteer.connect({ browserWSEndpoint, dumpio: true, defaultViewport: null });
console.log(2);
const pages = await browser.pages();
console.log(3);

if (pages.length < 1) {
console.log(4);
await stopBrowser();
throw new Error('did not find a renderer when connecting to app');
}
Expand Down

0 comments on commit a16c5e4

Please sign in to comment.