cloudflare/puppeteer

[Bug]: Minor update breaks the API

Closed this issue ยท 4 comments

Bug description

Steps to reproduce the problem:

  1. Update from 0.0.5 to "@cloudflare/puppeteer": "0.0.6"
  2. Build code that uses the connect() API
  3. Does not build

image

Note: this was working and perfectly fine in 0.0.5 - now this simple first instruction does not anymore, and this is not even a major API version (e.g. 2.0.0) but 0.0.6.

Puppeteer version

0.0.6

Node.js version

18

npm version

10.0.0.1

What operating system are you seeing the problem on?

Windows

Relevant log output

import { BrowserContext, connect, ScreenshotOptions, TimeoutError } from '@cloudflare/puppeteer';

...

  // [puppeteer] start the remote session
  const browser = await connect({ browserWSEndpoint });

...
./src/modules/browse/browse.router.ts:103:25
Type error: Expected 2 arguments, but got 1.

  101 |
  102 |   // [puppeteer] start the remote session
> 103 |   const browser = await connect({ browserWSEndpoint });
      |                         ^
  104 |
  105 |   // for local testing, open an incognito context, to seaparate cookies
  106 |   let incognitoContext: BrowserContext | null = null;

Hi Enrico,

Can you provide a complete example that worked before? Since we've always connected using a transport, did not expect that to actually work, ie. browserWSEndpoint = browser.wsEndpoint() would return an empty string, even if it did build.

Hi Enrico,

This package is a fork of the original puppeteer library and is only intended to support Cloudflare's browser rendering product, read more here. If you're using native puppeteer or other platforms like browserless.io you should use https://www.npmjs.com/package/puppeteer instead.

L480 commented

Same problem for me. I'm using @cloudflare/puppeteer with a third-party Chrome instance, which is not working anymore since 0.0.6. The standard puppeteer-core package seems to use unsupported node dependencies:

โœ˜ [ERROR] Could not resolve "fs/promises"

    node_modules/@puppeteer/browsers/lib/esm/fileUtil.js:8:31:
      8 โ”‚ import { mkdir, readdir } from 'fs/promises';
        โ•ต                                ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

Any idea how to fix that?

Please add to wrangler.toml

compatibility_date = "2023-03-14"
node_compat = true

or if using pages

npx wrangler pages dev [<DIRECTORY>] --compatibility-flags="nodejs_compat". See here