Giter Club home page Giter Club logo

puppeteer's Introduction

Workers version of Puppeteer Core

This repo is a fork of main puppeteer project. It creates a version of puppeteer core specialized for use in Cloudflare workers.

The goals of the fork are:

  • Support as much of the existing puppeteer core lib as possible.
  • Minimize the size of the library for workers developers, since library space is at a premium in workers projects.
  • Make library use as seamless as possible in workers.

Note that the main branch in this repo is branched off of version 17.0.0 of the library, to match the currently deployed version of Chromium on the edge.

More information in the developer docs.

Original README follows...

Puppeteer

Build status npm puppeteer package

Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.

What can I do?

Most things that you can do manually in the browser can be done using Puppeteer! Here are a few examples to get you started:

  • Generate screenshots and PDFs of pages.
  • Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. "SSR" (Server-Side Rendering)).
  • Automate form submission, UI testing, keyboard input, etc.
  • Create an up-to-date, automated testing environment. Run your tests directly in the latest version of Chrome using the latest JavaScript and browser features.
  • Capture a timeline trace of your site to help diagnose performance issues.
  • Test Chrome Extensions.

Getting Started

Installation

To use Puppeteer in your project, run:

npm i puppeteer
# or "yarn add puppeteer"

When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win) that is guaranteed to work with the API (customizable through Environment Variables). For a version of Puppeteer purely for connection, see puppeteer-core.

Environment Variables

Puppeteer looks for certain environment variables to aid its operations. If Puppeteer doesn't find them in the environment during the installation step, a lowercased variant of these variables will be used from the npm config.

  • HTTP_PROXY, HTTPS_PROXY, NO_PROXY - defines HTTP proxy settings that are used to download and run the browser.
  • PUPPETEER_SKIP_CHROMIUM_DOWNLOAD - do not download bundled Chromium during installation step.
  • PUPPETEER_TMP_DIR - defines the directory to be used by Puppeteer for creating temporary files. Defaults to os.tmpdir().
  • PUPPETEER_DOWNLOAD_HOST - overwrite URL prefix that is used to download Chromium. Note: this includes protocol and might even include path prefix. Defaults to https://storage.googleapis.com.
  • PUPPETEER_DOWNLOAD_PATH - overwrite the path for the downloads folder. Defaults to <root>/.local-chromium, where <root> is Puppeteer's package root.
  • PUPPETEER_CHROMIUM_REVISION - specify a certain version of Chromium you'd like Puppeteer to use. See puppeteer.launch on how executable path is inferred.
  • PUPPETEER_EXECUTABLE_PATH - specify an executable path to be used in puppeteer.launch.
  • PUPPETEER_PRODUCT - specify which browser you'd like Puppeteer to use. Must be one of chrome or firefox. This can also be used during installation to fetch the recommended browser binary. Setting product programmatically in puppeteer.launch supersedes this environment variable. The product is exposed in puppeteer.product
  • PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM — specify Puppeteer download Chromium for Apple M1. On Apple M1 devices Puppeteer by default downloads the version for Intel's processor which runs via Rosetta. It works without any problems, however, with this option, you should get more efficient resource usage (CPU and RAM) that could lead to a faster execution time.

:::danger

Puppeteer is only guaranteed to work with the bundled Chromium, use at your own risk.

:::

:::caution

PUPPETEER_* env variables are not accounted for in puppeteer-core.

:::

puppeteer-core

Every release since v1.7.0 we publish two packages:

puppeteer is a product for browser automation. When installed, it downloads a version of Chromium, which it then drives using puppeteer-core. Being an end-user product, puppeteer supports a bunch of convenient PUPPETEER_* env variables to tweak its behavior.

puppeteer-core is a library to help drive anything that supports DevTools protocol. puppeteer-core doesn't download Chromium when installed. Being a library, puppeteer-core is fully driven through its programmatic interface and disregards all the PUPPETEER_* env variables.

To sum up, the only differences between puppeteer-core and puppeteer are:

  • puppeteer-core doesn't automatically download Chromium when installed.
  • puppeteer-core ignores all PUPPETEER_* env variables.

In most cases, you'll be fine using the puppeteer package.

However, you should use puppeteer-core if:

  • you're building another end-user product or library atop of DevTools protocol. For example, one might build a PDF generator using puppeteer-core and write a custom install.js script that downloads headless_shell instead of Chromium to save disk space.
  • you're bundling Puppeteer to use in Chrome Extension / browser with the DevTools protocol where downloading an additional Chromium binary is unnecessary.
  • you're building a set of tools where puppeteer-core is one of the ingredients and you want to postpone install.js script execution until Chromium is about to be used.

When using puppeteer-core, remember to change the include line:

const puppeteer = require('puppeteer-core');

You will then need to call puppeteer.connect or puppeteer.launch with an explicit executablePath or channel option.

Usage

Puppeteer follows the latest maintenance LTS version of Node.

Puppeteer will be familiar to people using other browser testing frameworks. You create an instance of Browser, open pages, and then manipulate them with Puppeteer's API.

Example - navigating to https://example.com and saving a screenshot as example.png:

Save file as example.js

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();

Execute script on the command line

node example.js

Puppeteer sets an initial page size to 800×600px, which defines the screenshot size. The page size can be customized with Page.setViewport().

Example - create a PDF.

Save file as hn.js

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://news.ycombinator.com', {
    waitUntil: 'networkidle2',
  });
  await page.pdf({path: 'hn.pdf', format: 'a4'});

  await browser.close();
})();

Execute script on the command line

node hn.js

See Page.pdf for more information about creating pdfs.

Example - evaluate script in the context of the page

Save file as get-dimensions.js

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');

  // Get the "viewport" of the page, as reported by the page.
  const dimensions = await page.evaluate(() => {
    return {
      width: document.documentElement.clientWidth,
      height: document.documentElement.clientHeight,
      deviceScaleFactor: window.devicePixelRatio,
    };
  });

  console.log('Dimensions:', dimensions);

  await browser.close();
})();

Execute script on the command line

node get-dimensions.js

See Page.evaluate and related methods like Page.evaluateOnNewDocument and Page.exposeFunction.

Running in Docker

Puppeteer offers a Docker image that includes Chromium along with the required dependencies and a pre-installed Puppeteer version. The image is available via the GitHub Container Registry. The latest image is tagged as latest and other tags match Puppeteer versions. For example,

docker pull ghcr.io/puppeteer/puppeteer:latest # pulls the latest
docker pull ghcr.io/puppeteer/puppeteer:16.1.0 # pulls the image that contains Puppeteer v16.1.0

The image is meant for running the browser in the sandbox mode and therefore, running the image requires the SYS_ADMIN capability. For example,

docker run -i --init --cap-add=SYS_ADMIN --rm ghcr.io/puppeteer/puppeteer:latest node -e "`cat docker/test/smoke-test.js`"

Replace the path to smoke-test.js with a path to your script. The script can import or require the puppeteer module because it's pre-installed inside the image.

Currently, the image includes the LTS version of Node.js. If you need to build an image based on a different base image, you can use our Dockerfile as the starting point.

Working with Chrome Extensions

Puppeteer can be used for testing Chrome Extensions.

:::caution

Extensions in Chrome / Chromium currently only work in non-headless mode and experimental Chrome headless mode.

:::

The following is code for getting a handle to the background page of an extension whose source is located in ./my-extension:

const puppeteer = require('puppeteer');

(async () => {
  const pathToExtension = require('path').join(__dirname, 'my-extension');
  const browser = await puppeteer.launch({
    headless: 'chrome',
    args: [
      `--disable-extensions-except=${pathToExtension}`,
      `--load-extension=${pathToExtension}`,
    ],
  });
  const backgroundPageTarget = await browser.waitForTarget(
    target => target.type() === 'background_page'
  );
  const backgroundPage = await backgroundPageTarget.page();
  // Test the background page as you would any other page.
  await browser.close();
})();

:::note

Chrome Manifest V3 extensions have a background ServiceWorker of type 'service_worker', instead of a page of type 'background_page'.

:::

:::note

It is not yet possible to test extension popups or content scripts.

:::

Default runtime settings

1. Uses Headless mode

Puppeteer launches Chromium in headless mode. To launch a full version of Chromium, set the headless option when launching a browser:

const browser = await puppeteer.launch({headless: false}); // default is true

2. Runs a bundled version of Chromium

By default, Puppeteer downloads and uses a specific version of Chromium so its API is guaranteed to work out of the box. To use Puppeteer with a different version of Chrome or Chromium, pass in the executable's path when creating a Browser instance:

const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'});

You can also use Puppeteer with Firefox Nightly (experimental support). See Puppeteer.launch for more information.

See this article for a description of the differences between Chromium and Chrome. This article describes some differences for Linux users.

3. Creates a fresh user profile

Puppeteer creates its own browser user profile which it cleans up on every run.

Resources

Debugging tips

  1. Turn off headless mode - sometimes it's useful to see what the browser is displaying. Instead of launching in headless mode, launch a full version of the browser using headless: false:

    const browser = await puppeteer.launch({headless: false});
  2. Slow it down - the slowMo option slows down Puppeteer operations by the specified amount of milliseconds. It's another way to help see what's going on.

    const browser = await puppeteer.launch({
      headless: false,
      slowMo: 250, // slow down by 250ms
    });
  3. Capture console output - You can listen for the console event. This is also handy when debugging code in page.evaluate():

    page.on('console', msg => console.log('PAGE LOG:', msg.text()));
    
    await page.evaluate(() => console.log(`url is ${location.href}`));
  4. Use debugger in application code browser

    There are two execution context: node.js that is running test code, and the browser running application code being tested. This lets you debug code in the application code browser; ie code inside evaluate().

    • Use {devtools: true} when launching Puppeteer:

      const browser = await puppeteer.launch({devtools: true});
    • Change default test timeout:

      jest: jest.setTimeout(100000);

      jasmine: jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000;

      mocha: this.timeout(100000); (don't forget to change test to use function and not '=>')

    • Add an evaluate statement with debugger inside / add debugger to an existing evaluate statement:

      await page.evaluate(() => {
        debugger;
      });

      The test will now stop executing in the above evaluate statement, and chromium will stop in debug mode.

  5. Use debugger in node.js

    This will let you debug test code. For example, you can step over await page.click() in the node.js script and see the click happen in the application code browser.

    Note that you won't be able to run await page.click() in DevTools console due to this Chromium bug. So if you want to try something out, you have to add it to your test file.

    • Add debugger; to your test, eg:

      debugger;
      await page.click('a[target=_blank]');
    • Set headless to false

    • Run node --inspect-brk, eg node --inspect-brk node_modules/.bin/jest tests

    • In Chrome open chrome://inspect/#devices and click inspect

    • In the newly opened test browser, type F8 to resume test execution

    • Now your debugger will be hit and you can debug in the test browser

  6. Enable verbose logging - internal DevTools protocol traffic will be logged via the debug module under the puppeteer namespace.

     # Basic verbose logging
     env DEBUG="puppeteer:*" node script.js
    
     # Protocol traffic can be rather noisy. This example filters out all Network domain messages
     env DEBUG="puppeteer:*" env DEBUG_COLORS=true node script.js 2>&1 | grep -v '"Network'
    
  7. Debug your Puppeteer (node) code easily, using ndb

  • npm install -g ndb (or even better, use npx!)

  • add a debugger to your Puppeteer (node) code

  • add ndb (or npx ndb) before your test command. For example:

    ndb jest or ndb mocha (or npx ndb jest / npx ndb mocha)

  • debug your test inside chromium like a boss!

Contributing

Check out our contributing guide to get an overview of Puppeteer development.

FAQ

Our FAQ has migrated to our site.

puppeteer's People

Contributors

alixaxel avatar aslushnikov avatar avgp avatar christian-bromann avatar dependabot[bot] avatar ebidel avatar edevil avatar hanselfmu avatar jackfranklin avatar joeleinbinder avatar johanbay avatar jrandolf avatar jrandolf-zz avatar jschfflr avatar kblok avatar mathiasbynens avatar meddulla avatar mjzffr avatar orkon avatar paulirish avatar pavelfeldman avatar release-please[bot] avatar sadym-chromium avatar tasneemkoushar avatar thedavidbarton avatar timvdlippe avatar vsemozhetbyt avatar whimboo avatar yanivefraim avatar yury-s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppeteer's Issues

[Bug]: Puppeteer PDF generation via Page.pdf() method

Bug description

I was creating a simple html to pdf converter when I stumbled into a little issue with all the current version of the fork.

In the current implementation of the Page.pdf method in the @cloudflare/puppeteer fork, the Readable stream returned by Page.createPDFStream is converted to a Buffer by the function getReadableAsBuffer in puppeteer src/common /util.ts, where the problem is at. The getReadableAsBuffer function tries to iterate over a non iterable object(node:stream/Readable), what causes an TypeError: readable is not async iterable exception.

It can be easily solved by using Page.createPDFStream directly, but is still an issue which is not present in the @puppeteer/puppeteer-core package.

Steps to reproduce the problem:

  1. Launch puppeteer and instantiate a Page with some content:
const browser = await puppeteer.launch(env.MYBROWSER);
const page = await browser.newPage();
await page.setContent('<h1>HELLO CLOUDFLARE</h1>', {
waitUntil: 'networkidle0',
});
  1. Get the PDF:
 await page.pdf({ displayHeaderFooter: true })

Below is the link of a repo to reproduce the issue.
https://github.com/GiovaniMFMurari/cf-puppeteer-pdf-gen-test

Puppeteer version

0.0.6

Node.js version

16, 18 and 20

npm version

using pnpm 8.15.5

What operating system are you seeing the problem on?

Linux

Relevant log output

✘ [ERROR] Uncaught (in response) TypeError: readable is not async iterable

      at getReadableAsBuffer
      at Page.pdf
      at async Object.fetch
      at async drainBody

Upstream fixes/features syncing

It seems like this fork of puppeteer is based on v17.0.0 (released August 2022), whereas the latest version is v22.6.3 (released yesterday, April 2024)

Specifically, I'm looking to get deeper JS coverage information (by function scope), which has been possible since puppeteer v19, but not here, at least not according to the types for JSCoverageOptions missing useBlockCoverage.

What is the plan to keep this up to date with upstream puppeteer changes?

[Bug]: Minor update breaks the API

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;

[Bug]: Cannot read properties of undefined (reading 'fetch')

Bug description

Steps to reproduce the problem:

  1. Run the sample code from the developer documentation

Puppeteer version

0.0.5

Node.js version

18.18.1

npm version

9.8.1

What operating system are you seeing the problem on?

macOS

Relevant log output

 ⛅️ wrangler 3.13.1 (update available 3.13.2)                                                                                        
-------------------------------------------------------                                                                         
⎔ Starting local server...                                                                                             
[mf:inf] Ready on http://0.0.0.0:8787                                                                                                
[mf:inf] - http://127.0.0.1:8787                                                                                                           
[mf:inf] - http://192.168.0.6:8787                                                                                                   
[mf:inf] - http://192.168.64.1:8787                                                                                                        
[mf:err] TypeError: Cannot read properties of undefined (reading 'fetch')                                                            
    at PuppeteerWorkers.launch (/Users/count0/projects/silent-wind-e522/node_modules/@cloudflare/puppeteer/src/puppeteer-core.ts:66:32)         
    at Object.fetch (/Users/count0/projects/silent-wind-e522/src/index.ts:36:35)                                                     
    at __facade_modules_fetch__ (/private/var/folders/_c/br63y4ss5z13yhhrz4bsbnjh0000gn/T/tmp-43437-hYzTQ7KimFbI/middleware-loader.entry.ts:46:16)
    at __facade_invokeChain__ (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/common.ts:53:9)    
    at Object.next (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/common.ts:50:11)                         
    at jsonError (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30) 
    at __facade_invokeChain__ (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/common.ts:53:9)          
    at __facade_invoke__ (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/common.ts:63:9)                    
    at Object.fetch (/private/var/folders/_c/br63y4ss5z13yhhrz4bsbnjh0000gn/T/tmp-43437-hYzTQ7KimFbI/middleware-loader.entry.ts:114:11)              
[mf:inf] GET / 500 Internal Server Error (112ms)                                                                                           
[mf:err] TypeError: Cannot read properties of undefined (reading 'fetch')                                                                       
    at PuppeteerWorkers.launch (/Users/count0/projects/silent-wind-e522/node_modules/@cloudflare/puppeteer/src/puppeteer-core.ts:66:32)    
    at Object.fetch (/Users/count0/projects/silent-wind-e522/src/index.ts:36:35)                                                                
    at __facade_modules_fetch__ (/private/var/folders/_c/br63y4ss5z13yhhrz4bsbnjh0000gn/T/tmp-43437-hYzTQ7KimFbI/middleware-loader.entry.ts:46:16)
    at __facade_invokeChain__ (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/common.ts:53:9)    
    at Object.next (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/common.ts:50:11)                    
    at jsonError (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)
    at __facade_invokeChain__ (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/common.ts:53:9)          
    at __facade_invoke__ (/Users/count0/projects/silent-wind-e522/node_modules/wrangler/templates/middleware/common.ts:63:9)         
    at Object.fetch (/private/var/folders/_c/br63y4ss5z13yhhrz4bsbnjh0000gn/T/tmp-43437-hYzTQ7KimFbI/middleware-loader.entry.ts:114:11)
[mf:inf] GET /favicon.ico 500 Internal Server Error (56ms) 
スクリーンショット 2023-10-18 20 45 20

[Bug] Could not resolve "node:buffer"

Bug description

Getting error on build on Worker as well locally on Wrangler

Logs from Cloudflare Deployment

image

Logs from Wrangler

wrangler pages dev --proxy=3000 --compatibility-date=2023-09-04 --local

Error

Wrangler.toml

# Top-level configuration
name = "puppeteer"
main = "api/server.ts"
node_compat = true
workers_dev = true

browser = { binding = "MYBROWSER" }

Puppeteer version

0.0.5

Node.js version

18.17.1

npm version

10.1.0

What operating system are you seeing the problem on?

Windows

Relevant log output

16:29:00.466 | Found Functions directory at /functions. Uploading.
-- | --
16:29:01.918 | ✘ [ERROR] 3 error(s) and 0 warning(s) when compiling Worker.
16:29:01.919 |  
16:29:01.919 |  
16:29:01.922 |  
16:29:01.924 | ✘ [ERROR] Could not resolve "node:buffer"
16:29:01.924 |  
16:29:01.924 | ../node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/common/Page.js:47:23:
16:29:01.924 | 47 │ import { Buffer } from 'node:buffer';
16:29:01.925 |~~~~~~~~~~~~~

[Bug]: Unable to run @cloudflare/puppeteer in edge environment

Bug description

Steps to reproduce the problem:

  1. Use @cloudflare/next-on-pages package to deploy a Next.js application as full-stack using the edge runtime
  2. Change all endpoints to use the edge runtime
  3. Instead of using the original puppeteer library, use the @cloudflare/puppeteer that should be supported in an edge runtime
  4. build app using npx @cloudflare/next-on-pages@1

Puppeteer version

0.0.5

Node.js version

18.12

npm version

8.19.2

What operating system are you seeing the problem on?

macOS

Relevant log output

▲  Module build failed: UnhandledSchemeError: Reading from "node:stream" is not handled by plugins (Unhandled scheme).
▲  Webpack supports "data:" and "file:" URIs by default.
▲  You may need an additional plugin to handle "node:" URIs.
▲  at node_modules/.pnpm/[email protected][email protected][email protected].../node_modules/next/dist/compiled/webpack/bundle5.js:28:399772
▲  at Hook.eval [as callAsync] (eval at create (.../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:13:28867), <anonymous>:6:1)
▲  at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (.../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:13:26021)
▲  at Object.processResource (.../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:399697)
▲  at processResource (.../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
▲  at iteratePitchingLoaders (.../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
▲  at runLoaders (.../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
▲  at NormalModule._doBuild (.../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:399559)
▲  at NormalModule.build (.../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:401587)
▲  at .../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:81981
▲  
▲  Import trace for requested module:
▲  node:stream
▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/common/util.js
▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/common/BrowserConnector.js
▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/common/Puppeteer.js
▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/puppeteer-core.js
▲  ./app/api/get-resume/route.tsx
▲  ./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Fget-resume%2Froute&page=%2Fapi%2Fget-resume%2Froute&pagePath=private-next-app-dir%2Fapi%2Fget-resume%2Froute.tsx&appDir=%2F%2Fapp&appPaths=%2Fapi%2Fget-resume%2Froute&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!./app/api/get-resume/route.tsx?__next_edge_ssr_entry__
▲  
▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/common/ElementHandle.js:516:25
▲  Module not found: Can't resolve 'path'

▲  https://nextjs.org/docs/messages/module-not-found

▲  Import trace for requested module:
▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/common/QueryHandler.js
▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/puppeteer-core.js
▲  ./app/api/get-resume/route.tsx
▲  ./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js?absolutePagePath=private-next-app-dir%2Fapi%2Fget-resume%2Froute.tsx&page=%2Fapi%2Fget-resume%2Froute&appDirLoader=bmV4dC1hcHAtbG9hZGVyP25hbWU9YXBwJTJGYXBpJTJGZ2V0LXJlc3VtZSUyRnJvdXRlJnBhZ2U9JTJGYXBpJTJGZ2V0LXJlc3VtZSUyRnJvdXRlJnBhZ2VQYXRoPXByaXZhdGUtbmV4dC1hcHAtZGlyJTJGYXBpJTJGZ2V0LXJlc3VtZSUyRnJvdXRlLnRzeCZhcHBEaXI9JTJGVXNlcnMlMkZsa29yb2xpamElMkZjb2RlJTJGcGVyc29uYWwlMkZwcm9maWxlLWNoYXRib3QlMkZhcHAmYXBwUGF0aHM9JTJGYXBpJTJGZ2V0LXJlc3VtZSUyRnJvdXRlJnBhZ2VFeHRlbnNpb25zPXRzeCZwYWdlRXh0ZW5zaW9ucz10cyZwYWdlRXh0ZW5zaW9ucz1qc3gmcGFnZUV4dGVuc2lvbnM9anMmYmFzZVBhdGg9JmFzc2V0UHJlZml4PSZuZXh0Q29uZmlnT3V0cHV0PSZwcmVmZXJyZWRSZWdpb249Jm1pZGRsZXdhcmVDb25maWc9ZTMwJTNEIQ%3D%3D&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!

▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/common/IsolatedWorld.js:251:28
▲  Module not found: Can't resolve 'fs'
▲  
▲  https://nextjs.org/docs/messages/module-not-found
▲  
▲  Import trace for requested module:
▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/common/QueryHandler.js
▲  ./node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/puppeteer/lib/esm/puppeteer/puppeteer-core.js
▲  ./app/api/get-resume/route.tsx
▲  ./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js?absolutePagePath=private-next-app-dir%2Fapi%2Fget-resume%2Froute.tsx&page=%2Fapi%2Fget-resume%2Froute&appDirLoader=bmV4dC1hcHAtbG9hZGVyP25hbWU9YXBwJTJGYXBpJTJGZ2V0LXJlc3VtZSUyRnJvdXRlJnBhZ2U9JTJGYXBpJTJGZ2V0LXJlc3VtZSUyRnJvdXRlJnBhZ2VQYXRoPXByaXZhdGUtbmV4dC1hcHAtZGlyJTJGYXBpJTJGZ2V0LXJlc3VtZSUyRnJvdXRlLnRzeCZhcHBEaXI9JTJGVXNlcnMlMkZsa29yb2xpamElMkZjb2RlJTJGcGVyc29uYWwlMkZwcm9maWxlLWNoYXRib3QlMkZhcHAmYXBwUGF0aHM9JTJGYXBpJTJGZ2V0LXJlc3VtZSUyRnJvdXRlJnBhZ2VFeHRlbnNpb25zPXRzeCZwYWdlRXh0ZW5zaW9ucz10cyZwYWdlRXh0ZW5zaW9ucz1qc3gmcGFnZUV4dGVuc2lvbnM9anMmYmFzZVBhdGg9JmFzc2V0UHJlZml4PSZuZXh0Q29uZmlnT3V0cHV0PSZwcmVmZXJyZWRSZWdpb249Jm1pZGRsZXdhcmVDb25maWc9ZTMwJTNEIQ%3D%3D&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!> Build failed because of webpack errors

[Bug]: getting pdf is not a function

Bug description

Calling page.pdf() causes this error

Puppeteer version

latest

Node.js version

latest

npm version

latest

What operating system are you seeing the problem on?

macOS

Relevant log output

No response

[Bug]: page.waitForResponse results in "Buffer is not defined" error when reading response

Bug description

Steps to reproduce the problem:

const [res] = await Promise.all([
            page.waitForResponse(res => res.url().includes('something') && res.request().method().toUpperCase() != "OPTIONS"),
            page.goto('https://example.com', {waitUntil: "domcontentloaded"}),
        ]);

console.log(await res?.buffer())

You'll need to adjust the URL/matcher, but when you call res.buffer() (or .text() or .json()) it raises a Buffer is not defined error.

I tested the same code on the core Puppeteer library and it worked fine.

Puppeteer version

0.0.4

Node.js version

16

npm version

9.5.1

What operating system are you seeing the problem on?

macOS

Relevant log output

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.