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

[Bug]: Running as root without --no-sandbox In puppeteer #10233

Closed
2 tasks
RezaSalaari opened this issue May 23, 2023 · 5 comments
Closed
2 tasks

[Bug]: Running as root without --no-sandbox In puppeteer #10233

RezaSalaari opened this issue May 23, 2023 · 5 comments

Comments

@RezaSalaari
Copy link

Bug expectation

I have VPS with Ubuntu 20.0.4 version and I installed puppeteer on it if not passed the --no-sandbox argument

the Ubuntu has Error

:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180. TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md Error

but if I have pass this arguments headless: true, args: ['--no-sandbox'] puppeteer is launched but its has Error
open new Page Error: Evaluation failed: TypeError: Cannot read properties of null (reading 'querySelectorAll') at pptr://puppeteer_evaluation_script:3:24

Is There any way to Launch puppeteer without sandbox in Ubuntu? or if not please help me

Bug behavior

  • Flaky
  • PDF

Minimal, reproducible example

const Puppeteer = require("puppeteer");
let page = "";
async function doCrawl(){
try {
  const browser = await Puppeteer.launch({ 
   
    executablePath:'/usr/bin/chromium',
   args:['--no-sandbox','--disable-setuid-sandbox']
  });
  // Create a new page object
   page = await browser.newPage();
   console.log('open new Page');
  await page.goto("site Url ...", {
    waitUntil: "domcontentloaded",
    timeout: 0,
  });

  await page.waitForSelector("#technicalstudiesSubTabs");

  await page.click("xpath/" + '//*[@id="timePeriodsWidget"]/li[6]/a');
  await page.waitForTimeout(60000)
  const riskyPoints = await getR2AndS2();
  await page.waitForTimeout(8000)
  await page.click("xpath/" + '//*[@id="timePeriodsWidget"]/li[7]/a');
  await page.waitForTimeout(8000)
  const safePoints = await getR2AndS2();
  console.log('get Points',riskyPoints,safePoints);

  return {riskyPoints,safePoints}
} catch (error) {
  console.log(error,'error');
}
 

}

async function getR2AndS2() {
  const pivotPointsTable = await page.$("#curr_table > tbody ");
  const pivotPointsData = await page.evaluate((table) => {
    const data = [];
    const rows = table.querySelectorAll("tr");

    rows.forEach((row) => {
      const values = [];
      const cells = row.querySelectorAll("td");

      cells.forEach((cell) => {
        values.push(cell.innerText);
      });

      if (values.length) {
        data.push(values);
      }
    });

    return data;
  }, pivotPointsTable);

  const S2 = pivotPointsData[0][2];
  const R2 = pivotPointsData[0][6];
  return {
    Sell: Number(R2.split('.')[0]) - 1 +'.'+R2.split('.')[1] ,
   Buy: Number(S2.split('.')[0]) + 1 +'.'+S2.split('.')[1] } 
}

Error string

Error: Failed to launch the browser process! [0523/124928.433521:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180. TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

Puppeteer configuration

No response

Puppeteer version

18.2.1

Node version

18.12.0

Package manager

npm

Package manager version

8.19.2

Operating system

Linux

@github-actions
Copy link

This issue has an outdated Puppeteer version: 18.2.1. Please verify your issue on the latest 20.3.0 version. Then update the form accordingly.


Analyzer run

@OrKoN
Copy link
Collaborator

OrKoN commented May 23, 2023

Chromium does not support running as root without sandbox. See how to configure the sandbox https://pptr.dev/troubleshooting#setting-up-chrome-linux-sandbox It is recommended to create a dedicated user to run Puppeteer with a sandbox.

@OrKoN OrKoN closed this as completed May 23, 2023
@RezaSalaari
Copy link
Author

Chromium does not support running as root without sandbox. See how to configure the sandbox https://pptr.dev/troubleshooting#setting-up-chrome-linux-sandbox It is recommended to create a dedicated user to run Puppeteer with a sandbox.

I did all the instructions mentioned in your link but the second problem still persists
Error: Evaluation failed: TypeError: Cannot read properties of null (reading 'querySelectorAll')
while is worked on my Linux System if not passed ['--no-sandbox']

@OrKoN
Copy link
Collaborator

OrKoN commented May 23, 2023

That error means that table is null and your selector didn't find the right element on the page.

@RezaSalaari
Copy link
Author

But it works in normal mode without using sandbox and this problem occurs when it is run by sandbox.

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

No branches or pull requests

2 participants