berstend / puppeteer-extra

💯 Teach puppeteer new tricks through plugins.
https://extra.community
MIT License
6.54k stars 744 forks source link

[Bug] stuck browser.close() puppeteer-extra-plugin-stealth"^2.9.0" #618

Open rstorm861 opened 2 years ago

rstorm861 commented 2 years ago
  1. Run electron
  2. Press the button multiple times
  3. multiple browser starts up
  4. broeser.close()
  5. Stuck

If don't use stealth, it works fine https://github.com/rstorm861/puppeteer_test

index.html

<!DOCTYPE html>
<html>
  <head>
    <link
      rel="stylesheet"
      href="https://fonts.googleapis.com/icon?family=Material+Icons"
    />
    <link
      rel="stylesheet"
      href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
    />
    <meta charset="utf-8" />
    <title>test</title>
  </head>
  <body>
    <button onclick="onTest();">test</button>
  </body>

  <script>
    const ipcRenderer = window.api;
    function onTest() {
      ipcRenderer.send("test");
    }
  </script>
</html>

main.js

const { app, dialog, BrowserWindow } = require("electron");
const path = require("path");
const ipcMain = require("electron").ipcMain;

ipcMain.on("test", function (event, ...arg) {
  test();
});

const puppeteer = require("puppeteer-extra");
const StealthPlugin = require("puppeteer-extra-plugin-stealth");
puppeteer.use(StealthPlugin());

async function test() {
  puppeteer.launch({ headless: false, executablePath: chromepath }).then(async (browser) => {
    const page = await browser.newPage();
    await page.setViewport({ width: 800, height: 600 });
    await page.goto("https://bot.sannysoft.com");
    await browser.close();
  });
}

package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "electron ."
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "^17.0.0"
  },
  "dependencies": {
    "chrome-paths": "^1.0.1",
    "puppeteer-extra": "^3.2.3",
    "puppeteer-extra-plugin-stealth": "^2.9.0"
  }
}
C2BB commented 2 years ago

I'm having the same issue.

kbourro commented 2 years ago

@berstend mentioned on discord to use addExtra if you want to run multiple instances

berstend commented 2 years ago

Might be connected to #656