Giter Site home page Giter Site logo

heroku-buildpack-puppeteer-firefox's People

Contributors

aziz512 avatar harto avatar jkutner avatar jontewks avatar josephfrazier avatar kimpers avatar robertistok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kakamband easypag

heroku-buildpack-puppeteer-firefox's Issues

could not find the executable_path

    try:
        browser = playwright.firefox.launch(headless=headless)
        print('default is pass')
    except:
        executable_path=os.environ.get("firefox_executable_path")
        print('looking for env')

log keep to looking for env line

Bug - failed to use proxy

Hello @jontewks

Is it possible to use proxy with firefox ?
I have these error when I try :

2021-07-30T15:12:07.540974+00:00 app[web.1]: -- Launch browser with options --
2021-07-30T15:12:07.541392+00:00 app[web.1]: {
2021-07-30T15:12:07.541393+00:00 app[web.1]: product: 'firefox',
2021-07-30T15:12:07.541393+00:00 app[web.1]: args: [
2021-07-30T15:12:07.541393+00:00 app[web.1]: '--disable-extensions',
2021-07-30T15:12:07.541393+00:00 app[web.1]: '--no-sandbox',
2021-07-30T15:12:07.541394+00:00 app[web.1]: '--disable-setuid-sandbox',
2021-07-30T15:12:07.541394+00:00 app[web.1]: '--proxy-server=http://fr-pr.oxylabs.io:47777'
2021-07-30T15:12:07.541395+00:00 app[web.1]: ],
2021-07-30T15:12:07.541395+00:00 app[web.1]: ignoreHTTPSErrors: true
2021-07-30T15:12:07.541395+00:00 app[web.1]: }
2021-07-30T15:12:10.464877+00:00 app[web.1]: -- New page --
2021-07-30T15:12:10.732958+00:00 app[web.1]: -- Use Proxy --
2021-07-30T15:12:10.773042+00:00 app[web.1]: -- Browser close on get page error --
2021-07-30T15:12:11.412195+00:00 app[web.1]: Get page error : Protocol error (Fetch.enable): Fetch.enable RemoteAgentError@chrome://remote/content/cdp/Error.jsm:29:5
2021-07-30T15:12:11.412203+00:00 app[web.1]: UnknownMethodError@chrome://remote/content/cdp/Error.jsm:112:7
2021-07-30T15:12:11.412204+00:00 app[web.1]: execute@chrome://remote/content/cdp/domains/DomainCache.jsm:98:13
2021-07-30T15:12:11.412205+00:00 app[web.1]: receiveMessage@chrome://remote/content/cdp/sessions/ContentProcessSession.jsm:84:45
2021-07-30T15:12:11.412206+00:00 app[web.1]:
2021-07-30T15:12:11.413294+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: Error: Protocol error (Fetch.enable): Fetch.enable RemoteAgentError@chrome://remote/content/cdp/Error.jsm:29:5
2021-07-30T15:12:11.413295+00:00 app[web.1]: UnknownMethodError@chrome://remote/content/cdp/Error.jsm:112:7
2021-07-30T15:12:11.413295+00:00 app[web.1]: execute@chrome://remote/content/cdp/domains/DomainCache.jsm:98:13
2021-07-30T15:12:11.413296+00:00 app[web.1]: receiveMessage@chrome://remote/content/cdp/sessions/ContentProcessSession.jsm:84:45
2021-07-30T15:12:11.413296+00:00 app[web.1]:
2021-07-30T15:12:11.413297+00:00 app[web.1]: at /app/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:217:63
2021-07-30T15:12:11.413297+00:00 app[web.1]: at new Promise ()
2021-07-30T15:12:11.413298+00:00 app[web.1]: at CDPSession.send (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:216:16)
2021-07-30T15:12:11.413299+00:00 app[web.1]: at NetworkManager._updateProtocolRequestInterception (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/NetworkManager.js:167:30)
2021-07-30T15:12:11.413299+00:00 app[web.1]: at NetworkManager.authenticate (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/NetworkManager.js:108:20)
2021-07-30T15:12:11.413300+00:00 app[web.1]: at Page.authenticate (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:846:52)
2021-07-30T15:12:11.413300+00:00 app[web.1]: at getContent (/app/services/scrapper.service.js:44:18)
2021-07-30T15:12:11.413300+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:95:5)
2021-07-30T15:12:11.413302+00:00 app[web.1]: at async getPage (/app/controllers/scrapper.controller.js:13:20)
2021-07-30T15:12:11.413412+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

For info I have the same error when I'm doing a POST request
And it's working if I use Chrome product

Here is my code for proxy test

const options = {
  product: 'firefox',
  args: [
    '--disable-extensions',
    '--no-sandbox',
    '--disable-setuid-sandbox'
  ]
}

if ( proxy ) {
  options['ignoreHTTPSErrors'] = true
  options['args'].push('--proxy-server='+process.env.PROXY_URL)
}

console.log('-- Launch browser with options --');
console.log(options);
let browser
try {
  browser = await puppeteer.launch(options)
} catch (ex) {
  if ( browser ) {
    console.log('-- Browser close on launch error --');
    await browser.close();
  }
  console.error("Launch browser error : ", ex.message);
  throw ex;
}

let html
try {
  console.log('-- New page --');
  const page = await browser.newPage();

  if ( proxy ) {
    console.log('-- Use Proxy --');
    const username = process.env.PROXY_USER
    const password = process.env.PROXY_PASSWORD
    await page.authenticate({ username, password });
  }

  console.log('-- Goto --');
  console.log(url);
  await page.goto(url);
  html = await page.content();

  console.log('-- Browser close --');
  await browser.close();
} catch (ex) {
  console.log('-- Browser close on get page error --');
  await browser.close();
  console.error("Get page error : ", ex.message);
  throw ex;
}

Error: no DISPLAY environment variable specified

Error: Failed to launch the browser process!
Error: no DISPLAY environment variable specified


TROUBLESHOOTING: https://pptr.dev/troubleshooting

    at Interface.onClose (/app/node_modules/@puppeteer/browsers/lib/cjs/launch.js:310:24)
    at Interface.emit (node:events:530:35)
    at Interface.close (node:internal/readline/interface:527:10)
    at Socket.onend (node:internal/readline/interface:253:10)
    at Socket.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
 

I get this error on running my application with firefox buildpack.

How to solve this error?

Bug - Failed to launch the browser process!

Hello @jontewks

I'm using builpack-puppeteer-firefox on heroku and I have some problem

It's work fine after dyno restart, but after some successfull tries, the error appear.
The dyno memory seems to be ok.
I don't understand what happend

Thanks for your feedback

You can find the logs below (first logs are own console log to display launch browser options)

2021-07-12T09:36:37.342110+00:00 app[web.1]: -- Launch browser with options --
2021-07-12T09:36:37.342265+00:00 app[web.1]: {
2021-07-12T09:36:37.342266+00:00 app[web.1]: product: 'firefox',
2021-07-12T09:36:37.342267+00:00 app[web.1]: args: [
2021-07-12T09:36:37.342267+00:00 app[web.1]: '--disable-extensions',
2021-07-12T09:36:37.342267+00:00 app[web.1]: '--no-sandbox',
2021-07-12T09:36:37.342267+00:00 app[web.1]: '--disable-setuid-sandbox'
2021-07-12T09:36:37.342268+00:00 app[web.1]: ]
2021-07-12T09:36:37.342268+00:00 app[web.1]: }
2021-07-12T09:36:39.568656+00:00 app[web.1]: (node:21) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
2021-07-12T09:36:39.568664+00:00 app[web.1]: *** You are running in headless mode.
2021-07-12T09:36:39.568665+00:00 app[web.1]: JavaScript error: resource://gre/modules/PromiseWorker.jsm, line 189: NS_ERROR_UNEXPECTED
2021-07-12T09:36:39.568666+00:00 app[web.1]:
2021-07-12T09:36:39.568666+00:00 app[web.1]:
2021-07-12T09:36:39.568666+00:00 app[web.1]: TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
2021-07-12T09:36:39.568667+00:00 app[web.1]:
2021-07-12T09:36:39.568667+00:00 app[web.1]: at onClose (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:194:20)
2021-07-12T09:36:39.568690+00:00 app[web.1]: at ChildProcess. (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:185:79)
2021-07-12T09:36:39.568691+00:00 app[web.1]: at ChildProcess.emit (events.js:387:35)
2021-07-12T09:36:39.568692+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
2021-07-12T09:36:39.568758+00:00 app[web.1]: (node:21) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 9)

Can I use the older version of puppeteer firefox when deploying to Heroku?

Can I use the older version of puppeteer firefox (such as nightly firefox-96.0a1) when deploying to Heroku?
Please guide me the syntax code to do so.
In package.json if I use this preinstall script: "PUPPETEER_PRODUCT=firefox npm install puppeteer", they will get the newest version and I do not want that
Thank you very much!

Can't find executable path

When I deploy this code on Heroku the error shows that they can't find an executable firefox path

const puppeteer = require('puppeteer')
//const nodeCron = require("node-cron")
const sch = require("node-schedule")
//const ora = require("ora");
//const chalk = require("chalk");
const fs = require("fs/promises")
const mongo = require("mongodb").MongoClient

// Connect to MongoDB Database
const url = "";let db, TL
mongo.connect(
url,
{
useNewUrlParser: true,
useUnifiedTopology: true,
},
(err, client) => {
if (err) {
console.error(err)
return
}
db = client.db("TL")
TL = db.collection("TL")

async function VeederRoot() {
try {
const date = Date.now();
const browser = await puppeteer.launch({
headless: true,
//slowMo: 50,
product: 'firefox',
ignoreHTTPSErrors: true,
args: ['--ignore-certificate-errors', '--ignore-certificate-errors-spki-list', '--enable-features=NetworkService', '--no-sandbox',
'--disable-extensions','--use-gl=egl', '--disable-setuid-sandbox'],
ignoreDefaultArgs: ["--disable-extensions"],
//executablePath: 'C:/Program Files/Mozilla Firefox/firefox.exe',
FIREFOX_BIN: '/app/vendor/firefox/firefox',
//executablePath: '/app/vendor/firefox/firefox'
//executablePath: '/app/vendor/firefox/firefox'
//Selenium:WebDriver:Firefox:Binary.path = "/app/vendor/firefox/firefox"
})
const page = await browser.newPage()
console.time()
await page.goto('https://essotheone.thaiddns.com:4433/#LogIn')
console.time()
await page.type('#gwt-debug-userNameTextBox', "");
console.time()
await page.type('#gwt-debug-userPasswordTextBox', "");
await Promise.all([
page.click("#gwt-debug-signInButton"),
console.time(),
// page.click("#gwt-debug-tankItem4 > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(2) > a:nth-child(2)"),
page.waitForNavigation(),
console.time()
]);

await page.waitForSelector('#gwt-debug-tankItem1 > table:nth-child(1)');
    // Get data from Veeder-root web page      
    let data = await page.evaluate(() => {
      console.time()
       const items = Array.from(document.querySelectorAll('.TankOverviewTableItem'))
       console.time()
       let results = [];
       let allTank = [];
       let ts = Date.now();
         const dat = new Date(ts)
         console.time()
         const day = dat.getDate()
         console.time()
         const month = dat.getMonth() +1
         console.time()
         const year = dat.getFullYear()
         console.time()
        // const time = dat.getTi
         const date = `${day}/${month}/${year}`
       items.forEach((item) => {   
        console.time()
             const select = item.querySelectorAll("#_paramName.tank_item_div_height");
             console.time()
             const TankName = item.querySelector('.TankLabel');
             console.time()
             console.time(TankName)
             const T = TankName;
             //const D = fulldate;
             const V = select[0];
             console.time()
             console.time()
             const U = select[1];
             console.time()
             console.time()
             const W = select[2];
             console.time()
             console.time()
             const F = select[3];
             console.time()
             console.time()
             allTank.push({ TankName: T.innerText,
                Volume:V.innerText, 
                
                Ullage: U.innerText,
                Waterheight: W.innerText,
                Fuelheight: F.innerText
              })
               //url: item.getAttribute('data-url'),
               //Tank: item.querySelector('.TankLabel').innerText,
               //Volume: item.querySelector('.tank_item_div_height').textContent,
               //Ullage: item.querySelector('#gwt-debug-tankItem1 > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(2) > div:nth-child(1) > div:nth-child(2) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > div:nth-child(1)').textContent
           });
         results.push({
                date,
                //Time: D.innerText, 
                Tank: allTank,  
            });
            //console.time(data)
           return results
       });
        console.log(data)
        console.time()
        TL.insertMany(data)
        await browser.close()

} catch (error) {
console.error(error)
}
}
sch.scheduleJob("0 8 * * ",VeederRoot);
//sch.scheduleJob("
/30 * * * * *",VeederRoot);
VeederRoot()
//sch.cancelJob()
})

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.