mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
2 lines
47 KiB
JavaScript
2 lines
47 KiB
JavaScript
/*! For license information please see 992518d4.dca1fbe6.js.LICENSE.txt */
|
|
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[39541],{83599:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>u,contentTitle:()=>a,default:()=>h,frontMatter:()=>l,metadata:()=>c,toc:()=>d});var s=r(85893),o=r(11151),t=r(23277),i=r(64757);const l={},a="Troubleshooting",c={id:"troubleshooting",title:"Troubleshooting",description:"To keep this page up-to-date we largely rely on community contributions.",source:"@site/../docs/troubleshooting.md",sourceDirName:".",slug:"/troubleshooting",permalink:"/next/troubleshooting",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{},sidebar:"docs",previous:{title:"Contributing",permalink:"/next/contributing"},next:{title:"Links",permalink:"/next/guides/links"}},u={},d=[{value:"<code>Cannot find module 'puppeteer-core/internal/...'</code>",id:"cannot-find-module-puppeteer-coreinternal",level:2},{value:"<code>Could not find expected browser locally</code>",id:"could-not-find-expected-browser-locally",level:2},{value:"Chrome headless doesn't launch on Windows",id:"chrome-headless-doesnt-launch-on-windows",level:2},{value:"Chrome doesn't launch on Linux",id:"chrome-doesnt-launch-on-linux",level:2},{value:"chrome-headless-shell disables GPU compositing",id:"chrome-headless-shell-disables-gpu-compositing",level:2},{value:"Setting up GPU with Chrome",id:"setting-up-gpu-with-chrome",level:2},{value:"Setting Up Chrome Linux Sandbox",id:"setting-up-chrome-linux-sandbox",level:2},{value:"[recommended] Enable user namespace cloning",id:"recommended-enable-user-namespace-cloning",level:3},{value:"[alternative] Setup setuid sandbox",id:"alternative-setup-setuid-sandbox",level:3},{value:"Running Puppeteer on Travis CI",id:"running-puppeteer-on-travis-ci",level:2},{value:"Running Puppeteer on WSL (Windows subsystem for Linux)",id:"running-puppeteer-on-wsl-windows-subsystem-for-linux",level:2},{value:"Running Puppeteer on CircleCI",id:"running-puppeteer-on-circleci",level:2},{value:"Running Puppeteer in Docker",id:"running-puppeteer-in-docker",level:2},{value:"Running on Alpine",id:"running-on-alpine",level:3},{value:"Running Puppeteer on GitlabCI",id:"running-puppeteer-on-gitlabci",level:2},{value:"Running Puppeteer on Google Cloud Run",id:"running-puppeteer-on-google-cloud-run",level:2},{value:"Tips",id:"tips",level:4},{value:"Running Puppeteer in the cloud",id:"running-puppeteer-in-the-cloud",level:2},{value:"Running Puppeteer on Google App Engine",id:"running-puppeteer-on-google-app-engine",level:3},{value:"Running Puppeteer on Google Cloud Functions",id:"running-puppeteer-on-google-cloud-functions",level:3},{value:"Running Puppeteer on Google Cloud Run",id:"running-puppeteer-on-google-cloud-run-1",level:3},{value:"Running Puppeteer on Heroku",id:"running-puppeteer-on-heroku",level:3},{value:"Running Puppeteer on AWS Lambda",id:"running-puppeteer-on-aws-lambda",level:3},{value:"Running Puppeteer on AWS EC2 instance running Amazon-Linux",id:"running-puppeteer-on-aws-ec2-instance-running-amazon-linux",level:3},{value:"Code Transpilation Issues",id:"code-transpilation-issues",level:2}];function p(e){const n={a:"a",admonition:"admonition",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.a)(),...e.components},{Details:r}=n;return r||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"troubleshooting",children:"Troubleshooting"}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsx)(n.p,{children:"To keep this page up-to-date we largely rely on community contributions.\nPlease send a PR if you notice something is no longer up-to-date."})}),"\n",(0,s.jsx)(n.h2,{id:"cannot-find-module-puppeteer-coreinternal",children:(0,s.jsx)(n.code,{children:"Cannot find module 'puppeteer-core/internal/...'"})}),"\n",(0,s.jsxs)(n.p,{children:["This can occur if your Node.js version is lower than 14 or if you are using a\ncustom resolver (such as\n",(0,s.jsx)(n.a,{href:"https://www.npmjs.com/package/jest-resolve",children:(0,s.jsx)(n.code,{children:"jest-resolve"})}),"). For the former,\nwe do not support deprecated versions of Node.js. For the latter, usually\nupgrading the resolver (or its parent module such as ",(0,s.jsx)(n.code,{children:"jest"}),") will work (e.g.\n",(0,s.jsx)(n.a,{href:"https://github.com/puppeteer/puppeteer/issues/9121",children:"https://github.com/puppeteer/puppeteer/issues/9121"}),")"]}),"\n",(0,s.jsx)(n.h2,{id:"could-not-find-expected-browser-locally",children:(0,s.jsx)(n.code,{children:"Could not find expected browser locally"})}),"\n",(0,s.jsxs)(n.p,{children:["Starting from v19.0.0, Puppeteer will download browsers into\n",(0,s.jsx)(n.code,{children:"~/.cache/puppeteer"})," using\n",(0,s.jsx)(n.a,{href:"https://nodejs.org/api/os.html#oshomedir",children:(0,s.jsx)(n.code,{children:"os.homedir"})})," for better caching\nbetween Puppeteer upgrades. Generally the home directory is well-defined (even\non Windows), but occasionally the home directory may not be available. In this\ncase, we provide the ",(0,s.jsx)(n.code,{children:"PUPPETEER_CACHE_DIR"})," variable which allows you to change\nthe installation directory."]}),"\n",(0,s.jsx)(n.p,{children:"For example,"}),"\n",(0,s.jsxs)(t.Z,{groupId:"npm2yarn",children:[(0,s.jsx)(i.Z,{value:"npm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"PUPPETEER_CACHE_DIR=$(pwd) npm install puppeteer\nPUPPETEER_CACHE_DIR=$(pwd) node <script-path>\n"})})}),(0,s.jsx)(i.Z,{value:"yarn",label:"Yarn",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"PUPPETEER_CACHE_DIR=$(pwd) yarn add puppeteer\nPUPPETEER_CACHE_DIR=$(pwd) node <script-path>\n"})})}),(0,s.jsx)(i.Z,{value:"pnpm",label:"pnpm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"PUPPETEER_CACHE_DIR=$(pwd) pnpm add puppeteer\nPUPPETEER_CACHE_DIR=$(pwd) node <script-path>\n"})})})]}),"\n",(0,s.jsxs)(n.p,{children:["You can also create a configuration file named ",(0,s.jsx)(n.code,{children:".puppeteerrc.cjs"})," (or\n",(0,s.jsx)(n.code,{children:"puppeteer.config.cjs"}),") at the root of your application with the contents"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-js",children:"const {join} = require('path');\n\n/**\n * @type {import(\"puppeteer\").Configuration}\n */\nmodule.exports = {\n cacheDirectory: join(__dirname, '.cache', 'puppeteer'),\n};\n"})}),"\n",(0,s.jsxs)(n.p,{children:["You will need to reinstall ",(0,s.jsx)(n.code,{children:"puppeteer"})," in order for the configuration to take\neffect. See ",(0,s.jsx)(n.a,{href:"./guides/configuration",children:"Configuring Puppeteer"})," for more\ninformation."]}),"\n",(0,s.jsx)(n.h2,{id:"chrome-headless-doesnt-launch-on-windows",children:"Chrome headless doesn't launch on Windows"}),"\n",(0,s.jsxs)(n.p,{children:["Some ",(0,s.jsx)(n.a,{href:"https://support.google.com/chrome/a/answer/7532015",children:"chrome policies"})," might\nenforce running Chrome/Chromium with certain extensions."]}),"\n",(0,s.jsxs)(n.p,{children:["Puppeteer passes ",(0,s.jsx)(n.code,{children:"--disable-extensions"})," flag by default and will fail to launch\nwhen such policies are active."]}),"\n",(0,s.jsx)(n.p,{children:"To work around this, try running without the flag:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"const browser = await puppeteer.launch({\n ignoreDefaultArgs: ['--disable-extensions'],\n});\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["Context:\n",(0,s.jsx)(n.a,{href:"https://github.com/puppeteer/puppeteer/issues/3681#issuecomment-447865342",children:"issue 3681"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"chrome-doesnt-launch-on-linux",children:"Chrome doesn't launch on Linux"}),"\n",(0,s.jsxs)(n.p,{children:["Make sure all the necessary dependencies are installed. You can run ",(0,s.jsx)(n.code,{children:"ldd chrome | grep not"})," on a Linux machine to check which dependencies are missing. The\ncommon ones are provided below. Also, see\n",(0,s.jsx)(n.a,{href:"https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/debian/dist_package_versions.json",children:"https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/debian/dist_package_versions.json"}),"\nfor the up-to-date list of dependencies declared by the Chrome installer."]}),"\n",(0,s.jsx)(n.admonition,{type:"caution",children:(0,s.jsx)(n.p,{children:"Chrome currently does not provide arm64 binaries for Linux.\nThere are only arm64 binaries for Mac ARM.\nThat means that Linux binaries downloaded by default will not work on Linux arm64."})}),"\n",(0,s.jsxs)(r,{children:[(0,s.jsx)("summary",{children:"Debian (e.g. Ubuntu) Dependencies"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"ca-certificates\nfonts-liberation\nlibasound2\nlibatk-bridge2.0-0\nlibatk1.0-0\nlibc6\nlibcairo2\nlibcups2\nlibdbus-1-3\nlibexpat1\nlibfontconfig1\nlibgbm1\nlibgcc1\nlibglib2.0-0\nlibgtk-3-0\nlibnspr4\nlibnss3\nlibpango-1.0-0\nlibpangocairo-1.0-0\nlibstdc++6\nlibx11-6\nlibx11-xcb1\nlibxcb1\nlibxcomposite1\nlibxcursor1\nlibxdamage1\nlibxext6\nlibxfixes3\nlibxi6\nlibxrandr2\nlibxrender1\nlibxss1\nlibxtst6\nlsb-release\nwget\nxdg-utils\n"})})]}),"\n",(0,s.jsxs)(r,{children:[(0,s.jsx)("summary",{children:"CentOS Dependencies"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"alsa-lib.x86_64\natk.x86_64\ncups-libs.x86_64\ngtk3.x86_64\nipa-gothic-fonts\nlibXcomposite.x86_64\nlibXcursor.x86_64\nlibXdamage.x86_64\nlibXext.x86_64\nlibXi.x86_64\nlibXrandr.x86_64\nlibXScrnSaver.x86_64\nlibXtst.x86_64\npango.x86_64\nxorg-x11-fonts-100dpi\nxorg-x11-fonts-75dpi\nxorg-x11-fonts-cyrillic\nxorg-x11-fonts-misc\nxorg-x11-fonts-Type1\nxorg-x11-utils\n"})}),(0,s.jsxs)(n.p,{children:["After installing dependencies you need to update ",(0,s.jsx)(n.code,{children:"nss"})," library using this\ncommand"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"yum update nss -y\n"})})]}),"\n",(0,s.jsxs)(r,{children:[(0,s.jsx)("summary",{children:"Check out discussions"}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://github.com/puppeteer/puppeteer/issues/290",children:"#290"})," - Debian\ntroubleshooting ",(0,s.jsx)("br",{})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://github.com/puppeteer/puppeteer/issues/391",children:"#391"})," - CentOS\ntroubleshooting ",(0,s.jsx)("br",{})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://github.com/puppeteer/puppeteer/issues/379",children:"#379"})," - Alpine\ntroubleshooting ",(0,s.jsx)("br",{})]}),"\n"]})]}),"\n",(0,s.jsx)(n.h2,{id:"chrome-headless-shell-disables-gpu-compositing",children:"chrome-headless-shell disables GPU compositing"}),"\n",(0,s.jsxs)(n.p,{children:["chrome-headless-shell requires ",(0,s.jsx)(n.code,{children:"--enable-gpu"})," to\n",(0,s.jsx)(n.a,{href:"https://crbug.com/1416283",children:"enable GPU acceleration in headless mode"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"const browser = await puppeteer.launch({\n headless: 'shell',\n args: ['--enable-gpu'],\n});\n"})}),"\n",(0,s.jsx)(n.h2,{id:"setting-up-gpu-with-chrome",children:"Setting up GPU with Chrome"}),"\n",(0,s.jsxs)(n.p,{children:["Generally, Chrome should be able to detect and enable GPU if the system has appropriate drivers.\nFor additional tips, see the following blog post ",(0,s.jsx)(n.a,{href:"https://developer.chrome.com/blog/supercharge-web-ai-testing",children:"https://developer.chrome.com/blog/supercharge-web-ai-testing"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"setting-up-chrome-linux-sandbox",children:"Setting Up Chrome Linux Sandbox"}),"\n",(0,s.jsxs)(n.p,{children:["In order to protect the host environment from untrusted web content, Chrome uses\n",(0,s.jsx)(n.a,{href:"https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/sandboxing.md",children:"multiple layers of sandboxing"}),".\nFor this to work properly, the host should be configured first. If there's no\ngood sandbox for Chrome to use, it will crash with the error\n",(0,s.jsx)(n.code,{children:"No usable sandbox!"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["If you ",(0,s.jsx)(n.strong,{children:"absolutely trust"})," the content you open in Chrome, you can launch\nChrome with the ",(0,s.jsx)(n.code,{children:"--no-sandbox"})," argument:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"const browser = await puppeteer.launch({\n args: ['--no-sandbox', '--disable-setuid-sandbox'],\n});\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"caution",children:(0,s.jsxs)(n.p,{children:["Running without a sandbox is ",(0,s.jsx)(n.strong,{children:"strongly discouraged"}),". Consider configuring a\nsandbox instead."]})}),"\n",(0,s.jsx)(n.p,{children:"There are 2 ways to configure a sandbox in Chromium."}),"\n",(0,s.jsxs)(n.h3,{id:"recommended-enable-user-namespace-cloning",children:["[recommended] Enable ",(0,s.jsx)(n.a,{href:"http://man7.org/linux/man-pages/man7/user_namespaces.7.html",children:"user namespace cloning"})]}),"\n",(0,s.jsx)(n.p,{children:"User namespace cloning is only supported by modern kernels. Unprivileged user\nnamespaces are generally fine to enable, but in some cases they open up more\nkernel attack surface for (unsandboxed) non-root processes to elevate to kernel\nprivileges."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"sudo sysctl -w kernel.unprivileged_userns_clone=1\n"})}),"\n",(0,s.jsxs)(n.h3,{id:"alternative-setup-setuid-sandbox",children:["[alternative] Setup ",(0,s.jsx)(n.a,{href:"https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/suid_sandbox_development.md",children:"setuid sandbox"})]}),"\n",(0,s.jsx)(n.p,{children:"The setuid sandbox comes as a standalone executable and is located next to the\nChrome that Puppeteer downloads. It is fine to re-use the same sandbox\nexecutable for different Chrome versions, so the following could be done only\nonce per host environment:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"# cd to Puppeteer cache directory (adjust the path if using a different cache directory).\ncd ~/.cache/puppeteer/chrome/linux-<version>/chrome-linux64/\nsudo chown root:root chrome_sandbox\nsudo chmod 4755 chrome_sandbox\n# copy sandbox executable to a shared location\nsudo cp -p chrome_sandbox /usr/local/sbin/chrome-devel-sandbox\n# export CHROME_DEVEL_SANDBOX env variable\nexport CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox\n"})}),"\n",(0,s.jsxs)(n.p,{children:["You might want to export the ",(0,s.jsx)(n.code,{children:"CHROME_DEVEL_SANDBOX"})," env variable by default. In\nthis case, add the following to the ",(0,s.jsx)(n.code,{children:"~/.bashrc"})," or ",(0,s.jsx)(n.code,{children:".zshenv"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"export CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox\n"})}),"\n",(0,s.jsxs)(n.p,{children:["or to your ",(0,s.jsx)(n.code,{children:"Dockerfile"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"ENV CHROME_DEVEL_SANDBOX /usr/local/sbin/chrome-devel-sandbox\n"})}),"\n",(0,s.jsx)(n.h2,{id:"running-puppeteer-on-travis-ci",children:"Running Puppeteer on Travis CI"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\ud83d\udc4b We ran our tests for Puppeteer on Travis CI until v6.0.0 (when we've\nmigrated to GitHub Actions) - see our historical\n",(0,s.jsxs)(n.a,{href:"https://github.com/puppeteer/puppeteer/blob/v5.5.0/.travis.yml",children:[(0,s.jsx)(n.code,{children:".travis.yml"})," (v5.5.0)"]}),"\nfor reference."]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"Tips-n-tricks:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Xvfb",children:"xvfb"})," service should be launched in order\nto run Chromium in non-headless mode"]}),"\n",(0,s.jsx)(n.li,{children:"Runs on Xenial Linux on Travis by default"}),"\n",(0,s.jsxs)(n.li,{children:["Runs ",(0,s.jsx)(n.code,{children:"npm install"})," by default"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"node_modules"})," is cached by default"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:".travis.yml"})," might look like this:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yml",children:"language: node_js\nnode_js: node\nservices: xvfb\nscript:\n - npm test\n"})}),"\n",(0,s.jsx)(n.h2,{id:"running-puppeteer-on-wsl-windows-subsystem-for-linux",children:"Running Puppeteer on WSL (Windows subsystem for Linux)"}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"https://github.com/puppeteer/puppeteer/issues/1837",children:"this thread"})," with some\ntips specific to WSL. In a nutshell, you need to install missing dependencies by\neither:"]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps#install-google-chrome-for-linux",children:"Installing Chrome on WSL to install all dependencies"})}),"\n",(0,s.jsxs)(n.li,{children:["Installing required dependencies manually:\n",(0,s.jsx)(n.code,{children:"sudo apt install libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.admonition,{type:"caution",children:(0,s.jsx)(n.p,{children:"The list of required dependencies might get outdated and depend on what you\nalready have installed."})}),"\n",(0,s.jsx)(n.h2,{id:"running-puppeteer-on-circleci",children:"Running Puppeteer on CircleCI"}),"\n",(0,s.jsx)(n.p,{children:"Running Puppeteer smoothly on CircleCI requires the following steps:"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["Start with a\n",(0,s.jsx)(n.a,{href:"https://circleci.com/docs/2.0/circleci-images/#nodejs",children:"NodeJS image"})," in your\nconfig like so:","\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yaml",children:"docker:\n - image: circleci/node:14 # Use your desired version\n environment:\n NODE_ENV: development # Only needed if puppeteer is in `devDependencies`\n"})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["Dependencies like ",(0,s.jsx)(n.code,{children:"libXtst6"})," probably need to be installed via ",(0,s.jsx)(n.code,{children:"apt-get"}),", so\nuse the\n",(0,s.jsx)(n.a,{href:"https://circleci.com/orbs/registry/orb/threetreeslight/puppeteer",children:"threetreeslight/puppeteer"}),"\norb\n(",(0,s.jsx)(n.a,{href:"https://circleci.com/orbs/registry/orb/threetreeslight/puppeteer#quick-start",children:"instructions"}),"),\nor paste parts of its\n",(0,s.jsx)(n.a,{href:"https://circleci.com/orbs/registry/orb/threetreeslight/puppeteer#orb-source",children:"source"}),"\ninto your own config."]}),"\n",(0,s.jsxs)(n.li,{children:["Lastly, if you\u2019re using Puppeteer through Jest, then you may encounter an\nerror spawning child processes:","\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"[00:00.0] jest args: --e2e --spec --max-workers=36\nError: spawn ENOMEM\n at ChildProcess.spawn (internal/child_process.js:394:11)\n"})}),"\n","This is likely caused by Jest autodetecting the number of processes on the\nentire machine (",(0,s.jsx)(n.code,{children:"36"}),") rather than the number allowed to your container (",(0,s.jsx)(n.code,{children:"2"}),").\nTo fix this, set ",(0,s.jsx)(n.code,{children:"jest --maxWorkers=2"})," in your test command."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"running-puppeteer-in-docker",children:"Running Puppeteer in Docker"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\ud83d\udc4b We used ",(0,s.jsx)(n.a,{href:"https://cirrus-ci.org/",children:"Cirrus Ci"})," to run our tests for Puppeteer\nin a Docker container until v3.0.x - see our historical\n",(0,s.jsxs)(n.a,{href:"https://github.com/puppeteer/puppeteer/blob/v3.0.1/.ci/node12/Dockerfile.linux",children:[(0,s.jsx)(n.code,{children:"Dockerfile.linux"})," (v3.0.1)"]}),"\nfor reference. Starting from v16.0.0 we are shipping a Docker image via the\nGitHub registry. The Dockerfile is located\n",(0,s.jsx)(n.a,{href:"https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile",children:"here"})," and\nthe usage instructions are in the\n",(0,s.jsx)(n.a,{href:"https://github.com/puppeteer/puppeteer#running-in-docker",children:"README.md"}),". The\ninstructions below might be still helpful if you are building your own image."]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"Getting headless Chrome up and running in Docker can be tricky. The bundled\nChromium that Puppeteer installs is missing the necessary shared library\ndependencies."}),"\n",(0,s.jsx)(n.p,{children:"To fix, you'll need to install the missing dependencies and the latest Chromium\npackage in your Dockerfile:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Dockerfile",children:"FROM node:14-slim\n\n# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)\n# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer\n# installs, work.\nRUN apt-get update \\\n && apt-get install -y wget gnupg \\\n && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \\\n && sh -c 'echo \"deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main\" >> /etc/apt/sources.list.d/google.list' \\\n && apt-get update \\\n && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \\\n --no-install-recommends \\\n && rm -rf /var/lib/apt/lists/*\n\n# If running Docker >= 1.13.0 use docker run's --init arg to reap zombie processes, otherwise\n# uncomment the following lines to have `dumb-init` as PID 1\n# ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_x86_64 /usr/local/bin/dumb-init\n# RUN chmod +x /usr/local/bin/dumb-init\n# ENTRYPOINT [\"dumb-init\", \"--\"]\n\n# Uncomment to skip the chromium download when installing puppeteer. If you do,\n# you'll need to launch puppeteer with:\n# browser.launch({executablePath: 'google-chrome-stable'})\n# ENV PUPPETEER_SKIP_DOWNLOAD true\n\n# Install puppeteer so it's available in the container.\nRUN npm init -y && \\\n npm i puppeteer \\\n # Add user so we don't need --no-sandbox.\n # same layer as npm install to keep re-chowned files from using up several hundred MBs more space\n && groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \\\n && mkdir -p /home/pptruser/Downloads \\\n && chown -R pptruser:pptruser /home/pptruser \\\n && chown -R pptruser:pptruser /node_modules \\\n && chown -R pptruser:pptruser /package.json \\\n && chown -R pptruser:pptruser /package-lock.json\n\n# Run everything after as non-privileged user.\nUSER pptruser\n\nCMD [\"google-chrome-stable\"]\n"})}),"\n",(0,s.jsx)(n.p,{children:"Build the container:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"docker build -t puppeteer-chrome-linux .\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Run the container by passing ",(0,s.jsx)(n.code,{children:'node -e "<yourscript.js content as a string>"'})," as\nthe command:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:' docker run -i --init --rm --cap-add=SYS_ADMIN \\\n --name puppeteer-chrome puppeteer-chrome-linux \\\n node -e "`cat yourscript.js`"\n'})}),"\n",(0,s.jsxs)(n.p,{children:["There's a full example at ",(0,s.jsx)(n.a,{href:"https://github.com/ebidel/try-puppeteer",children:"https://github.com/ebidel/try-puppeteer"})," that shows how\nto run this Dockerfile from a webserver running on App Engine Flex (Node)."]}),"\n",(0,s.jsx)(n.h3,{id:"running-on-alpine",children:"Running on Alpine"}),"\n",(0,s.jsxs)(n.p,{children:["The\n",(0,s.jsx)(n.a,{href:"https://pkgs.alpinelinux.org/package/edge/community/x86_64/chromium",children:"newest Chromium package"}),"\nsupported on Alpine is 100, which corresponds to\n",(0,s.jsx)(n.a,{href:"https://github.com/puppeteer/puppeteer/releases/tag/v13.5.0",children:"Puppeteer v13.5.0"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Example Dockerfile:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Dockerfile",children:"FROM alpine\n\n# Installs latest Chromium (100) package.\nRUN apk add --no-cache \\\n chromium \\\n nss \\\n freetype \\\n harfbuzz \\\n ca-certificates \\\n ttf-freefont \\\n nodejs \\\n yarn\n\n...\n\n# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.\nENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser\n\n# Puppeteer v13.5.0 works with Chromium 100.\nRUN yarn add puppeteer@13.5.0\n\n# Add user so we don't need --no-sandbox.\nRUN addgroup -S pptruser && adduser -S -G pptruser pptruser \\\n && mkdir -p /home/pptruser/Downloads /app \\\n && chown -R pptruser:pptruser /home/pptruser \\\n && chown -R pptruser:pptruser /app\n\n# Run everything after as non-privileged user.\nUSER pptruser\n\n...\n"})}),"\n",(0,s.jsx)(n.h2,{id:"running-puppeteer-on-gitlabci",children:"Running Puppeteer on GitlabCI"}),"\n",(0,s.jsx)(n.p,{children:"This is very similar to some of the instructions above, but require a bit\ndifferent configuration to finally achieve success."}),"\n",(0,s.jsx)(n.p,{children:"Usually the issue looks like this:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"Error: Failed to launch chrome! spawn /usr/bin/chromium-browser ENOENT\n"})}),"\n",(0,s.jsx)(n.p,{children:"You need to patch two places:"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["Your ",(0,s.jsx)(n.code,{children:"gitlab-ci.yml"})," config"]}),"\n",(0,s.jsx)(n.li,{children:"Arguments' list when launching puppeteer"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["In ",(0,s.jsx)(n.code,{children:"gitlab-ci.yml"})," we need to install some packages to make it possible to\nlaunch headless Chrome in your docker env:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yml",children:"before_script:\n - apt-get update\n - apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2\n libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4\n libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0\n libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1\n libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1\n libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release\n xdg-utils wget\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Next, you have to use ",(0,s.jsx)(n.code,{children:"'--no-sandbox'"})," mode and also\n",(0,s.jsx)(n.code,{children:"'--disable-setuid-sandbox'"})," when launching Puppeteer. This can be done by\npassing them as an arguments to your ",(0,s.jsx)(n.code,{children:".launch()"})," call:\n",(0,s.jsx)(n.code,{children:"puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"running-puppeteer-on-google-cloud-run",children:"Running Puppeteer on Google Cloud Run"}),"\n",(0,s.jsx)(n.p,{children:'Google Cloud Run disables the CPU by default, after an HTTP response is written to the client. This means that puppeteer will appear extremely slow (taking 1-5 minutes to launch), if you "run puppeteer in the background" after your response has been written.'}),"\n",(0,s.jsx)(n.p,{children:"So this simple express app will be percievably slow:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-js",children:"import express from 'express';\n\nconst app = express();\n\napp.post('/test-puppeteer', (req, res) => {\n res.json({\n jobId: 123,\n acknowledged: true,\n });\n\n puppeteer.launch().then(browser => {\n // 2 minutes later...\n });\n});\n\napp.listen(3000);\n"})}),"\n",(0,s.jsx)(n.p,{children:"It is slow because CPU is disabled on GCR because puppeteer is launched after the response is sent. What you want to do is this:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-js",children:"app.post('/test-puppeteer', (req, res) => {\n puppeteer.launch().then(browser => {\n // A second later...\n res.json({\n jobId: 123,\n acknowledged: true,\n });\n });\n});\n"})}),"\n",(0,s.jsx)(n.p,{children:'If you want to run the stuff in the background, you need to "enable CPU always" even after responses are sent. That should fix it.'}),"\n",(0,s.jsx)(n.h4,{id:"tips",children:"Tips"}),"\n",(0,s.jsxs)(n.p,{children:["By default, Docker runs a container with a ",(0,s.jsx)(n.code,{children:"/dev/shm"})," shared memory space 64MB.\nThis is ",(0,s.jsx)(n.a,{href:"https://github.com/c0b/chrome-in-docker/issues/1",children:"typically too small"}),"\nfor Chrome and will cause Chrome to crash when rendering large pages. To fix,\nrun the container with ",(0,s.jsx)(n.code,{children:"docker run --shm-size=1gb"})," to increase the size of\n",(0,s.jsx)(n.code,{children:"/dev/shm"}),". Since Chrome 65, this is no longer necessary. Instead, launch the\nbrowser with the ",(0,s.jsx)(n.code,{children:"--disable-dev-shm-usage"})," flag:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"const browser = await puppeteer.launch({\n args: ['--disable-dev-shm-usage'],\n});\n"})}),"\n",(0,s.jsxs)(n.p,{children:["This will write shared memory files into ",(0,s.jsx)(n.code,{children:"/tmp"})," instead of ",(0,s.jsx)(n.code,{children:"/dev/shm"}),". See\n",(0,s.jsx)(n.a,{href:"https://bugs.chromium.org/p/chromium/issues/detail?id=736452",children:"crbug.com/736452"}),"\nfor more details."]}),"\n",(0,s.jsxs)(n.p,{children:["Seeing other weird errors when launching Chrome? Try running your container with\n",(0,s.jsx)(n.code,{children:"docker run --cap-add=SYS_ADMIN"})," when developing locally. Since the Dockerfile\nadds a ",(0,s.jsx)(n.code,{children:"pptr"})," user as a non-privileged user, it may not have all the necessary\nprivileges."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://github.com/Yelp/dumb-init",children:"dumb-init"})," is worth checking out if you're\nexperiencing a lot of zombies Chrome processes sticking around. There's special\ntreatment for processes with PID=1, which makes it hard to terminate Chrome\nproperly in some cases (e.g. in Docker)."]}),"\n",(0,s.jsx)(n.h2,{id:"running-puppeteer-in-the-cloud",children:"Running Puppeteer in the cloud"}),"\n",(0,s.jsx)(n.h3,{id:"running-puppeteer-on-google-app-engine",children:"Running Puppeteer on Google App Engine"}),"\n",(0,s.jsxs)(n.p,{children:["The Node.js runtime of the\n",(0,s.jsx)(n.a,{href:"https://cloud.google.com/appengine/docs/standard/nodejs/",children:"App Engine standard environment"}),"\ncomes with all system packages needed to run Headless Chrome."]}),"\n",(0,s.jsxs)(n.p,{children:["To use ",(0,s.jsx)(n.code,{children:"puppeteer"}),", specify the module as a dependency in your ",(0,s.jsx)(n.code,{children:"package.json"}),"\nand then override the puppeteer cache directory by including a file named\n",(0,s.jsx)(n.code,{children:".puppeteerrc.cjs"})," at the root of your application with the contents:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"const {join} = require('path');\n\n/**\n * @type {import(\"puppeteer\").Configuration}\n */\nmodule.exports = {\n cacheDirectory: join(__dirname, 'node_modules', '.puppeteer_cache'),\n};\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["[!NOTE]\nGoogle App Engine caches your ",(0,s.jsx)(n.code,{children:"node_modules"})," between builds.\nSpecifying the Puppeteer cache as subdirectory of ",(0,s.jsx)(n.code,{children:"node_modules"}),"\nmitigates an issue in which Puppeteer can't find the browser executable\ndue to ",(0,s.jsx)(n.code,{children:"postinstall"})," not being run."]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"running-puppeteer-on-google-cloud-functions",children:"Running Puppeteer on Google Cloud Functions"}),"\n",(0,s.jsxs)(n.p,{children:["The Node.js runtime of\n",(0,s.jsx)(n.a,{href:"https://cloud.google.com/functions/docs/",children:"Google Cloud Functions"}),"\ncomes with all system packages needed to run Headless Chrome."]}),"\n",(0,s.jsxs)(n.p,{children:["To use ",(0,s.jsx)(n.code,{children:"puppeteer"}),", specify the module as a dependency in your ",(0,s.jsx)(n.code,{children:"package.json"}),"\nand then override the puppeteer cache directory by including a file named\n",(0,s.jsx)(n.code,{children:".puppeteerrc.cjs"})," at the root of your application with the contents:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"const {join} = require('path');\n\n/**\n * @type {import(\"puppeteer\").Configuration}\n */\nmodule.exports = {\n cacheDirectory: join(__dirname, 'node_modules', '.puppeteer_cache'),\n};\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["[!NOTE]\nGoogle Cloud Functions caches your ",(0,s.jsx)(n.code,{children:"node_modules"})," between builds. Specifying the\npuppeteer cache as subdirectory of ",(0,s.jsx)(n.code,{children:"node_modules"})," mitigates an issue in which the\npuppeteer install process does not run when the cache is hit."]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"running-puppeteer-on-google-cloud-run-1",children:"Running Puppeteer on Google Cloud Run"}),"\n",(0,s.jsxs)(n.p,{children:["The default Node.js runtime of\n",(0,s.jsx)(n.a,{href:"https://cloud.google.com/run/docs/",children:"Google Cloud Run"})," does not come with the\nsystem packages needed to run Headless Chrome. You will need to set up your own\n",(0,s.jsx)(n.code,{children:"Dockerfile"})," and\n",(0,s.jsx)(n.a,{href:"#chrome-doesnt-launch-on-linux",children:"include the missing dependencies"}),"."]}),"\n",(0,s.jsx)(n.h3,{id:"running-puppeteer-on-heroku",children:"Running Puppeteer on Heroku"}),"\n",(0,s.jsx)(n.p,{children:"Running Puppeteer on Heroku requires some additional dependencies that aren't\nincluded on the Linux box that Heroku spins up for you. To add the dependencies\non deploy, add the Puppeteer Heroku buildpack to the list of buildpacks for your\napp under Settings > Buildpacks."}),"\n",(0,s.jsxs)(n.p,{children:["The url for the buildpack is\n",(0,s.jsx)(n.a,{href:"https://github.com/jontewks/puppeteer-heroku-buildpack",children:"https://github.com/jontewks/puppeteer-heroku-buildpack"})]}),"\n",(0,s.jsxs)(n.p,{children:["Ensure that you're using ",(0,s.jsx)(n.code,{children:"'--no-sandbox'"})," mode when launching Puppeteer. This\ncan be done by passing it as an argument to your ",(0,s.jsx)(n.code,{children:".launch()"})," call:\n",(0,s.jsx)(n.code,{children:"puppeteer.launch({ args: ['--no-sandbox'] });"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"When you click add buildpack, simply paste that url into the input, and click\nsave. On the next deploy, your app will also install the dependencies that\nPuppeteer needs to run."}),"\n",(0,s.jsxs)(n.p,{children:["If you need to render Chinese, Japanese, or Korean characters you may need to\nuse a buildpack with additional font files like\n",(0,s.jsx)(n.a,{href:"https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack",children:"https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack"})]}),"\n",(0,s.jsxs)(n.p,{children:["There's also another\n",(0,s.jsx)(n.a,{href:"https://timleland.com/headless-chrome-on-heroku/",children:"simple guide"})," from @timleland\nthat includes a sample project:\n",(0,s.jsx)(n.a,{href:"https://timleland.com/headless-chrome-on-heroku/",children:"https://timleland.com/headless-chrome-on-heroku/"}),"."]}),"\n",(0,s.jsx)(n.h3,{id:"running-puppeteer-on-aws-lambda",children:"Running Puppeteer on AWS Lambda"}),"\n",(0,s.jsxs)(n.p,{children:["AWS Lambda ",(0,s.jsx)(n.a,{href:"https://docs.aws.amazon.com/lambda/latest/dg/limits.html",children:"limits"}),"\ndeployment package sizes to ~50MB. This presents challenges for running headless\nChrome (and therefore Puppeteer) on Lambda. The community has put together a few\nresources that work around the issues:"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://github.com/sparticuz/chromium",children:"https://github.com/sparticuz/chromium"})," (a vendor and framework agnostic library that supports modern versions of ",(0,s.jsx)(n.code,{children:"chromium"}),")"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://github.com/alixaxel/chrome-aws-lambda",children:"https://github.com/alixaxel/chrome-aws-lambda"})," (supports up to puppeteer 10.1 - outdated)"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://github.com/adieuadieu/serverless-chrome/blob/HEAD/docs/chrome.md",children:"https://github.com/adieuadieu/serverless-chrome/blob/HEAD/docs/chrome.md"}),"\n(serverless plugin - outdated)"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"running-puppeteer-on-aws-ec2-instance-running-amazon-linux",children:"Running Puppeteer on AWS EC2 instance running Amazon-Linux"}),"\n",(0,s.jsx)(n.p,{children:"If you are using an EC2 instance running amazon-linux in your CI/CD pipeline,\nand if you want to run Puppeteer tests in amazon-linux, follow these steps."}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["To install Chromium, you have to first enable ",(0,s.jsx)(n.code,{children:"amazon-linux-extras"})," which\ncomes as part of\n",(0,s.jsx)(n.a,{href:"https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/",children:"EPEL (Extra Packages for Enterprise Linux)"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"sudo amazon-linux-extras install epel -y\n"})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Next, install Chromium:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"sudo yum install -y chromium\n"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["Now Puppeteer can launch Chromium to run your tests. If you do not enable EPEL\nand if you continue installing chromium as part of ",(0,s.jsx)(n.code,{children:"npm install"}),", Puppeteer\ncannot launch Chromium due to unavailability of ",(0,s.jsx)(n.code,{children:"libatk-1.0.so.0"})," and many more\npackages."]}),"\n",(0,s.jsx)(n.h2,{id:"code-transpilation-issues",children:"Code Transpilation Issues"}),"\n",(0,s.jsxs)(n.p,{children:["If you are using a JavaScript transpiler like babel or TypeScript, calling\n",(0,s.jsx)(n.code,{children:"evaluate()"})," with an async function might not work. This is because while\n",(0,s.jsx)(n.code,{children:"puppeteer"})," uses ",(0,s.jsx)(n.code,{children:"Function.prototype.toString()"})," to serialize functions while\ntranspilers could be changing the output code in such a way it's incompatible\nwith ",(0,s.jsx)(n.code,{children:"puppeteer"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Some workarounds to this problem would be to instruct the transpiler not to mess\nup with the code, for example, configure TypeScript to use latest ecma version\n(",(0,s.jsx)(n.code,{children:'"target": "es2018"'}),"). Another workaround could be using string templates\ninstead of functions:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"await page.evaluate(`(async() => {\n console.log('1');\n})()`);\n"})})]})}function h(e={}){const{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(p,{...e})}):p(e)}},75251:(e,n,r)=>{var s=r(67294),o=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(e,n,r){var s,t={},c=null,u=null;for(s in void 0!==r&&(c=""+r),void 0!==n.key&&(c=""+n.key),void 0!==n.ref&&(u=n.ref),n)i.call(n,s)&&!a.hasOwnProperty(s)&&(t[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===t[s]&&(t[s]=n[s]);return{$$typeof:o,type:e,key:c,ref:u,props:t,_owner:l.current}}n.Fragment=t,n.jsx=c,n.jsxs=c},85893:(e,n,r)=>{e.exports=r(75251)},64757:(e,n,r)=>{r.d(n,{Z:()=>i});var s=r(67294),o=r(90512);const t={tabItem:"tabItem__kUE"};function i({children:e,hidden:n,className:r}){return s.createElement("div",{role:"tabpanel",className:(0,o.Z)(t.tabItem,r),hidden:n},e)}},23277:(e,n,r)=>{r.d(n,{Z:()=>E});var s=r(67294),o=r(90512),t=r(6379),i=r(16550),l=r(11666),a=r(47348),c=r(83928),u=r(76632);function d(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function p(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):function(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);n&&(s=s.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,s)}return r}(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})),e}function h(e){var n,r;return null!==(r=null===(n=s.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,s.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)})))||void 0===n?void 0:n.filter(Boolean))&&void 0!==r?r:[]}function m(e){const{values:n,children:r}=e;return(0,s.useMemo)((()=>{const e=null!=n?n:function(e){return h(e).map((({props:{value:e,label:n,attributes:r,default:s}})=>({value:e,label:n,attributes:r,default:s})))}(r);return function(e){const n=(0,c.l)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e}),[n,r])}function g({value:e,tabValues:n}){return n.some((n=>n.value===e))}function b({queryString:e=!1,groupId:n}){const r=(0,i.k6)(),o=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return null!=n?n:null}({queryString:e,groupId:n}),t=(0,a._X)(o),l=(0,s.useCallback)((e=>{if(!o)return;const n=new URLSearchParams(r.location.search);n.set(o,e),r.replace(p(function(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},s=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),s.forEach((function(n){d(e,n,r[n])}))}return e}({},r.location),{search:n.toString()}))}),[o,r]);return[t,l]}function x(e){const{defaultValue:n,queryString:r=!1,groupId:o}=e,t=m(e),[i,a]=(0,s.useState)((()=>function({defaultValue:e,tabValues:n}){if(0===n.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!g({value:e,tabValues:n}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}var r;const s=null!==(r=n.find((e=>e.default)))&&void 0!==r?r:n[0];if(!s)throw new Error("Unexpected error: 0 tabValues");return s.value}({defaultValue:n,tabValues:t}))),[c,d]=b({queryString:r,groupId:o}),[p,h]=function({groupId:e}){const n=function(e){return e?`docusaurus.tab.${e}`:null}(e),[r,o]=(0,u.Nk)(n);return[r,(0,s.useCallback)((e=>{n&&o.set(e)}),[n,o])]}({groupId:o}),x=(()=>{const e=null!=c?c:p;return g({value:e,tabValues:t})?e:null})();(0,l.Z)((()=>{x&&a(x)}),[x]);return{selectedValue:i,selectValue:(0,s.useCallback)((e=>{if(!g({value:e,tabValues:t}))throw new Error(`Can't select invalid tab value=${e}`);a(e),d(e),h(e)}),[d,h,t]),tabValues:t}}var f=r(30358);const j={tabList:"tabList_fbd4",tabItem:"tabItem_v5XY"};function y(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function w(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},s=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),s.forEach((function(n){y(e,n,r[n])}))}return e}function v(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):function(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);n&&(s=s.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,s)}return r}(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})),e}function k({className:e,block:n,selectedValue:r,selectValue:i,tabValues:l}){const a=[],{blockElementScrollPositionUntilNextRender:c}=(0,t.o5)(),u=e=>{const n=e.currentTarget,s=a.indexOf(n),o=l[s].value;o!==r&&(c(n),i(o))},d=e=>{let n=null;switch(e.key){case"Enter":u(e);break;case"ArrowRight":{const s=a.indexOf(e.currentTarget)+1;var r;n=null!==(r=a[s])&&void 0!==r?r:a[0];break}case"ArrowLeft":{const r=a.indexOf(e.currentTarget)-1;var s;n=null!==(s=a[r])&&void 0!==s?s:a[a.length-1];break}}null==n||n.focus()};return s.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,o.Z)("tabs",{"tabs--block":n},e)},l.map((({value:e,label:n,attributes:t})=>s.createElement("li",v(w({role:"tab",tabIndex:r===e?0:-1,"aria-selected":r===e,key:e,ref:e=>a.push(e),onKeyDown:d,onClick:u},t),{className:(0,o.Z)("tabs__item",j.tabItem,null==t?void 0:t.className,{"tabs__item--active":r===e})}),null!=n?n:e))))}function C({lazy:e,children:n,selectedValue:r}){const o=(Array.isArray(n)?n:[n]).filter(Boolean);if(e){const e=o.find((e=>e.props.value===r));return e?(0,s.cloneElement)(e,{className:"margin-top--md"}):null}return s.createElement("div",{className:"margin-top--md"},o.map(((e,n)=>(0,s.cloneElement)(e,{key:n,hidden:e.props.value!==r}))))}function P(e){const n=x(e);return s.createElement("div",{className:(0,o.Z)("tabs-container",j.tabList)},s.createElement(k,w({},n,e)),s.createElement(C,w({},n,e)))}function E(e){const n=(0,f.Z)();return s.createElement(P,w({key:String(n)},e),h(e.children))}},11151:(e,n,r)=>{r.d(n,{Z:()=>l,a:()=>i});var s=r(67294);const o={},t=s.createContext(o);function i(e){const n=s.useContext(t);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),s.createElement(t.Provider,{value:n},e.children)}}}]); |