Skip to content

TargetCloseError: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed. #2838

Description

@caetano157

Description

When i trying to get the QRCode, this issue happen's

Environment

  • Venom version(s): venom-bot@5.3.0
  • Browser: Chromium 117.0.5938.0
  • OS: "Rocky Linux 9.5 (Blue Onyx)
  • Node version: v18.20.4

Steps to Reproduce

just tried to start the app
another time, I managed to read the qrcode at the same time and the same error occurred.

 Page successfully accessed
Erro inicializando o client: Not Logged
TargetCloseError: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
    at CdpCDPSession.send (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CDPSession.js:64:35)
    at #evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:202:50)
    at ExecutionContext.evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:117:36)
    at IsolatedWorld.evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:124:30)
    at CdpFrame.evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:353:43)
    at CdpFrame.<anonymous> (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:98:27)
    at CdpPage.evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:841:43)
    at Whatsapp.initService (/home/codarhub/apps_nodejs/WappServer/node_modules/venom-bot/dist/api/whatsapp.js:59:58)
    at /home/codarhub/apps_nodejs/WappServer/node_modules/venom-bot/dist/api/whatsapp.js:47:24
TargetCloseError: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
    at CdpCDPSession.send (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CDPSession.js:64:35)
    at #evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:202:50)
    at ExecutionContext.evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:117:36)
    at IsolatedWorld.evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:124:30)
    at CdpFrame.evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:353:43)
    at CdpFrame.<anonymous> (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:98:27)
    at CdpPage.evaluate (/home/codarhub/apps_nodejs/WappServer/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:841:43)
    at Whatsapp.addChatWapi (/home/codarhub/apps_nodejs/WappServer/node_modules/venom-bot/dist/api/whatsapp.js:88:25)
    at /home/codarhub/apps_nodejs/WappServer/node_modules/venom-bot/dist/api/whatsapp.js:48:24
const app = express();
const path = require('path');
const router = express.Router();
const bodyParser = require('body-parser')
const venom = require('venom-bot');
let client; // Declare the client variable at the top level to have access in the entire application
const port = process.env.PORT || 21117; 
console.log("Rodando na porta:" + port)
venom
    .create({
        session: 'G4', //name of session
        browserArgs: ['--no-sandbox', '--disable-setuid-sandbox'],
        browserPathExecutable: '/home/codarhub/chromium/chrome-linux/chrome' // Caminho do Chromium portátil
    })
    .then((waClient) => {
        client = waClient; // Store the client instance in the variable
        start(client);
        console.log("Client iniciliazou com sucesso");
    })
    .catch((error) => {
        console.log("Erro inicializando o client:", error);
    });```

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageNeeds avaliation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions