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

Error: Failed to launch the browser process! undefined #2341

Open
phillipnunes opened this issue Sep 12, 2024 · 1 comment
Open

Error: Failed to launch the browser process! undefined #2341

phillipnunes opened this issue Sep 12, 2024 · 1 comment
Labels
bug Something isn't working needs triage

Comments

@phillipnunes
Copy link

Description

Ao tentar criar duas ou mais sessões usando a biblioteca, acontece o erro postado mais abaixo. A primeirão é criada normalmente, mas ao chamar a mesma API mais de uma vez o erro ocorre. Por algum motivo ele tenta abrir as sessões posteriores usando um nome antigo de sessão (que já existe na pasta tokens).

Note no log abaixo que o nome da sessão printado no terminal (b96f6ea5-8151-48bb-91b2-d13020f3b7f6) não corresponde ao do caminho que ele tentou criar (Failed to create /home/phillip/Documents/Repositories/teste/api/tokens/cc548742-baf3-426e-a9f9-9c06a80feebf/...)

Mesmo passando o parametro folderNameToken explicitamente, o erro acontece.

O estranho é que quando passo essa prop abaixo no create (puppeteerOptions), ai funciona.
O puppeteerOptions é obrigatório? Porque preciso passar ele pra dar certo?

puppeteerOptions: {
  userDataDir: `./tokens/${sessionName}`,
},

Environment

  • WPPConnect version(s): 1.34.1
  • WA-JS version(s): 3.10.1
  • Browser: Não sei qual ele usa
  • OS: Ubuntu 22.04
  • Node version: 20.13.1
  • WhatsApp version: 2.3000.1015690181
  • MultiDevice (BETA): Não sei o que seria isso

Log Output

sessionName b96f6ea5-8151-48bb-91b2-d13020f3b7f6
info:     [b96f6ea5-8151-48bb-91b2-d13020f3b7f6:browser] Using browser folder '/home/phillip/Documents/Repositories/teste/api/tokens/cc548742-baf3-426e-a9f9-9c06a80feebf/cc548742-baf3-426e-a9f9-9c06a80feebf'
info:     [b96f6ea5-8151-48bb-91b2-d13020f3b7f6:browser] Initializing browser...
error:    [b96f6ea5-8151-48bb-91b2-d13020f3b7f6:browser] Error no open browser
error:    [b96f6ea5-8151-48bb-91b2-d13020f3b7f6:browser] Failed to launch the browser process! undefined
[23463:23463:0911/214426.374148:ERROR:process_singleton_posix.cc(335)] Failed to create /home/phillip/Documents/Repositories/teste/api/tokens/cc548742-baf3-426e-a9f9-9c06a80feebf/cc548742-baf3-426e-a9f9-9c06a80feebf/SingletonLock: File exists (17)
[23463:23463:0911/214426.374374:ERROR:chrome_main_delegate.cc(594)] Failed to create a ProcessSingleton for your profile directory. This means that running multiple instances would start multiple browser processes rather than opening a new window in the existing process. Aborting now to avoid profile corruption.


TROUBLESHOOTING: https://pptr.dev/troubleshooting

Error: Failed to launch the browser process! undefined
[23463:23463:0911/214426.374148:ERROR:process_singleton_posix.cc(335)] Failed to create /home/phillip/Documents/Repositories/teste/api/tokens/cc548742-baf3-426e-a9f9-9c06a80feebf/cc548742-baf3-426e-a9f9-9c06a80feebf/SingletonLock: File exists (17)
[23463:23463:0911/214426.374374:ERROR:chrome_main_delegate.cc(594)] Failed to create a ProcessSingleton for your profile directory. This means that running multiple instances would start multiple browser processes rather than opening a new window in the existing process. Aborting now to avoid profile corruption.


TROUBLESHOOTING: https://pptr.dev/troubleshooting

    at ChildProcess.onClose (/home/phillip/Documents/Repositories/teste/api/node_modules/@puppeteer/browsers/src/launch.ts:486:11)
    at ChildProcess.emit (node:events:531:35)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12)

Your Code

export class WhatsappService {
  constructor() {}

  async createSession(data: CreateSession, res: Response) {
    const sessionName = uuidv4();
    console.log('sessionName', sessionName);
    try {
      const client = await create({
        session: sessionName,
        debug: true,
        folderNameToken: `./tokens/${sessionName}`,
        // puppeteerOptions: {
        //   userDataDir: `./tokens/${sessionName}`,
        // },
        catchQR: (base64Qr) => {
          if (res && !res.headersSent) {
            res.status(200).json({
              status: 'QRCODE',
              imageBase64: base64Qr,
            });
          }
        },
        logQR: false,
      });

      this.start(client);
    } catch (error) {
      console.log(error);
    }
  }

  start(client) {
    client.onMessage((message) => {
      if (message.body === 'Hi' && message.isGroupMsg === false) {
        client
          .sendText(message.from, 'Welcome to Wppconnect')
          .then((result) => console.log('Result', result))
          .catch((error) => {
            console.error('Error when sending: ', error); //return error object
          });
      }
    });
  }
}
@phillipnunes phillipnunes added bug Something isn't working needs triage labels Sep 12, 2024
@Saifallak
Copy link

Delete SingletonLock file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants