Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing pipe option in puppeteer.launch([options]) #56

Open
hwogrpw opened this issue Jul 13, 2022 · 1 comment
Open

Missing pipe option in puppeteer.launch([options]) #56

hwogrpw opened this issue Jul 13, 2022 · 1 comment

Comments

@hwogrpw
Copy link

hwogrpw commented Jul 13, 2022

When the following code is ran, a WebSocket connection to the browser is established.

const browser = await puppeteer.launch({pipe: true});

But according to puppeteer.launch, a pipe should be used instead:

pipe <boolean> Connects to the browser over a pipe instead of a WebSocket. Defaults to false.

Seems the code doesn't care about the pipe option:

const {
ignoreDefaultArgs = false,
args = [],
executablePath = null,
env = Deno.env.toObject(),
ignoreHTTPSErrors = false,
defaultViewport = { width: 800, height: 600 },
slowMo = 0,
timeout = 30000,
dumpio = false,
} = options;

@hwogrpw hwogrpw changed the title Missing pipe option in puppeteer.launch(options) Missing pipe option in puppeteer.launch([options]) Jul 13, 2022
@AlexJeffcott
Copy link

This is likely because the pipe option does not work in Deno which makes the compatibility claim in https://deno.com/blog/v1.35 a little confusing.

Assuming you have “installed” a browser with deno run -q --no-lock -A --unstable --no-check --reload npm:puppeteer/install.mjs, the following code works with deno run -A index.mjs (it does have a “Warning: Not implemented: ClientRequest.options.createConnection”, though).

// index.mjs
import puppeteer from 'npm:puppeteer'

(async () => {
  const browser = await puppeteer.launch({
    headless: 'new',
    pipe: false
  });
  const page = await browser.newPage();
  await page.goto('https://developer.chrome.com/');
  await page.setViewport({width: 1920, height: 1080});
  await page.screenshot({path: './test.jpg'})
  await browser.close();
  Deno.exit(1)
})();

But with pipe: true it breaks with the same deno run -A index.mjs command.
Here is the output: error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on').

You can find the same issue with regards to Playwright support. See denoland/deno#16899 (comment) and microsoft/playwright#3146 (comment)

// index.mjs
import puppeteer from 'npm:puppeteer'

(async () => {
  const browser = await puppeteer.launch({
    headless: 'new',
    pipe: true
  });
  const page = await browser.newPage();
  await page.goto('https://developer.chrome.com/');
  await page.setViewport({width: 1920, height: 1080});
  await page.screenshot({path: './test.jpg'})
  await browser.close();
  Deno.exit(1)
})();

Here is the same in Node (assuming that you have installed Puppeteer with npm i puppeteer which works just fine with the pipe option by running node index.mjs.

// index.mjs
import puppeteer from 'puppeteer'

(async () => {
  const browser = await puppeteer.launch({
      headless: 'new',
      pipe: true
  });
  const page = await browser.newPage();
  
  await page.goto('https://developer.chrome.com/');
  await page.setViewport({width: 1920, height: 1080});
  await page.screenshot({path: './test.jpg'})
  await browser.close();
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants