Giter Site home page Giter Site logo

Comments (8)

zfcsoftware avatar zfcsoftware commented on July 30, 2024 1

Hi, Puppeteer stops working when an error is received (even when closing the browser) but chromium does not. This causes the browser to hang as you mentioned. I am working on this bug and will fix it.

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on July 30, 2024

Please add your code. If you get an error, the program stops but chrome does not. It may be caused by this.

from puppeteer-real-browser.

ibrahimmus avatar ibrahimmus commented on July 30, 2024

The whole logic is in try catch and finally block, and in finally block I have await browser.close().
I will paste the code example later but FYI the same code was working with puppeteer and puppeteer stealth previously. I did not get into this situation of having multiple chrome processes hanging

from puppeteer-real-browser.

ibrahimmus avatar ibrahimmus commented on July 30, 2024

Just run these two scripts together. Only run the second one, first one needs to be in the same path.

////FIRST SCRIPT

import { connect } from 'puppeteer-real-browser'

const main = async () => {
const {browser, page} = await connect({
headless: 'auto',
args: [],
customConfig: {},
skipTarget: [],
fingerprint: false,
turnstile: false,
connectOption: {},
tf: true,
})
await page.goto('https://antoinevastel.com/bots/datadome');
await page.evaluate(() => {
return new Promise(resolve => {
setTimeout(resolve, 20000);
});
});
await browser.close();
process.exit(0);
}

main();

//SECOND SCRIPT

import { fork } from 'child_process';

const maxForks = 5; // Maximum number of forks allowed
let runningForks = 0; // Initialize the number of running forks

const startFork = () => {
const child = fork('./${NAME_OF_FIRST_SCRIPT}'); // Fork the main script

// Event handler for when the forked process exits
child.on('exit', () => {
    runningForks--; // Decrement the count of running forks
    if (runningForks < maxForks) {
        startFork(); // Start a new fork if the count is less than the maximum
    }
});

runningForks++; // Increment the count of running forks

}

// Start initial forks
for (let i = 0; i < maxForks; i++) {
startFork();
}

from puppeteer-real-browser.

ibrahimmus avatar ibrahimmus commented on July 30, 2024

@zfcsoftware is there any way I could help you with this to speed it up? This is the only thing that blocks me in using/testing this in my case. Thanks

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on July 30, 2024

@zfcsoftware is there any way I could help you with this to speed it up? This is the only thing that blocks me in using/testing this in my case. Thanks

Hello,

chrome: chrome,

You can use the chrome.close() method.

from puppeteer-real-browser.

ibrahimmus avatar ibrahimmus commented on July 30, 2024

@zfcsoftware there is only chrome.kill() option. So you are telling me to get chrome instance back from connect method response and work with it as a temp solution?

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on July 30, 2024

The chrome variable is already returned, yes you can use it that way. Normally this problem does not occur under normal conditions, but it may occur when an error is received, I need to examine it in detail.
https://github.com/zfcsoftware/cf-clearance-scraper/blob/main/module/browser.js
You can create a browser like this and try that too.

from puppeteer-real-browser.

Related Issues (20)

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.