wppconnect-team / wppconnect

WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination
https://wppconnect.io
Other
1.92k stars 337 forks source link

Protocol error (Runtime. callFunctionn): Target closed. #2253

Closed ethan2cl closed 4 months ago

ethan2cl commented 4 months ago

Description

[Description of the bug, When Issue Happens]

Environment

Steps to Reproduce

  1. [First Step] login wpp
  2. [Second Step] Send 5-10 10M-20M video files at once using the sendFile API

Log Output

ProtocolError: Protocol error (Runtime. callFunctionn): Target closed.

Your Code

await client.sendFile(param.destJid, base64, {
      type,
      filename,
      caption,
      quotedMsg,
      mentionedList,
      isPtt: req.file.mimetype.endsWith('.ogg'),
      // waitForAck: true,
    });

I have made some modifications to the sendFile method to support quoted messages src/api/layers/sender.layer.ts

return evaluateAndReturn(
      this.page,
      async ({ to, base64, options }) => {
        let quotedMsg;
        if (options.quotedMsg) {
          quotedMsg = WAPI.covertToQuotedMsg(options.quotedMsg);
          delete options.quotedMsg;
        }
        const result = await WPP.chat.sendFileMessage(to, base64, {
          ...options,
          quotedMsg,
        });
        return {
          ack: result.ack,
          id: result.id,
          sendMsgResult: await result.sendMsgResult,
        };
      },
      { to, base64, options: options as any }
    );

Additional context / Screenshot

This is also an occasional phenomenon. The probability of triggering it in the afternoon of Chinese time is relatively high. I suspect that it is due to the frequent API calls detected by WA official testing, but currently it seems more like a problem caused by using Puppetter. Have you encountered it before and how can you solve it🥹 image

ethan2cl commented 4 months ago

After sending a large number of media files, it is necessary to wait for a while before triggering this issue. After "Target Close", any API of the session cannot be used, but the browser process still exists

icleitoncosta commented 4 months ago

In this case, this error is related to Puppeteer. I'm trying to find possible causes, but I haven't been able to identify it yet because it's a random event.

How many sessions are connected, and what are the server configurations?

ethan2cl commented 4 months ago

In this case, this error is related to Puppeteer. I'm trying to find possible causes, but I haven't been able to identify it yet because it's a random event.

How many sessions are connected, and what are the server configurations?

Only two sessions were logged in locally, and the server environment is Ubuntu 22.04 LTS (4C16G). It should be a random event. The day before, I tried again and couldn't reproduce this situation. I think it may be due to the increased detection intensity of frequent API calls after the release of the new version of WA last week. I have also consulted some information about Puppeteer and have a rough idea of the problem. Thank you for your reply.

devactivity-app[bot] commented 4 months ago

@ethan2cl, ⭐3 XP earned, 🏆First Comment Added completed, 💪Level 1 achieved! Contribute more to raise your XP/Level, complete challenges for extra achievements! [Sign up for personal dashboard]

icon
devactivity-app[bot] commented 4 months ago

@ethan2cl, ⭐3 XP earned, 🏆First Issue Closed completed, 💪Level 1 achieved! Contribute more to raise your XP/Level, complete challenges for extra achievements! [Sign up for personal dashboard]

icon