open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.09k stars 591 forks source link

Unable to get all messages for a specific chat id + inconsistent send buttons delivery #2658

Closed blackchineykh closed 2 years ago

blackchineykh commented 2 years ago

Are you using the latest version of the library?

What type of session are you experiencing this issue on?

Multi-device and I have set multiDevice to true in my config OR am using the --multi-device flag

What type of host account are you experiencing this issue on?

Personal account (normal)

Mode

My own code

Current Behavior

When calling the load and get all messages in a for a specific chat, its not returning and seems to have an ever incrementing counter in the devtools as seen in my screenshot. Its just going up. I think this may be also causing the instance to hang for certain functions?

await this.whatsapp.loadAndGetAllMessagesInChat(
      chatId,
      false,
      false
    ); 

Expected Behavior

Messages should be returned for the specific chat

Steps To Reproduce

  1. Run the library with my own code
  2. Request to load all messages for a specific chat
  3. No results are returned and chrome dev tools shows an ever incrementing "loading more messages" output going over 1 million times.

create() code

create({
    sessionId: sessionId,
    sessionDataPath: sessionDataPath,
    useChrome: true,
    restartOnCrash: start,
    headless: process.env.CHROME_HEADLESS === "true",
    resizable: true,
    throwErrorOnTosBlock: true,
    qrTimeout: 0, //set to 0 to wait forever for a qr scan
    authTimeout: 0, //set to 0 to wait forever for connection to phone
    killProcessOnBrowserClose: false, //need to be false to support reload of service from GUI
    autoRefresh: true,
    safeMode: false,
    disableSpins: false,
    qrRefreshS: 15,
    cacheEnabled: false,
    blockCrashLogs: true,
    useStealth: true,
    licenseKey: process.env.WA_LICENSE,
    multiDevice: process.env.MULTI_DEVICE === "true",

  })

DEBUG INFO

{
  "WA_VERSION": "2.2212.7",
  "WA_AUTOMATE_VERSION": "4.35.3",
  "BROWSER_VERSION": "Chrome/100.0.4896.88",
  "START_TS": 1649885922522,
  "LATEST_VERSION": true,
  "CLI": false,
  "LAUNCH_TIME_MS": 30300,
  "ACC_TYPE": "PERSONAL",
  "chats": 511,
  "messages": 96,
  "contacts": 7681,
  "isMd": true,
  "INSTANCE_ID": "cce2e5c9-dce5-4d0c-a0d3-a7bcc4bcccdb"
}

Environment

- OS: macOS Monterey
- Node: 12.22.10
- npm: 6.14.16

Screenshots/Logs

image

image

Anything else?

I also noticed that the sending buttons will not get delivered to some contacts. On WA Web, it just shows the timer icon indicating its not yet sent. If I restart, that message clears completely and never gets sent (like it wasnt even attempted even though it showed in the web). This behaviour isnt consistent between restarts while toggling headless mode.

Im wondering if its related to something else like this issue happening in the background?

smashah commented 2 years ago

@blackchineykh how many messages are in this conversation?

blackchineykh commented 2 years ago

@blackchineykh how many messages are in this conversation?

Less than 30 messages

smashah commented 2 years ago

@blackchineykh I think this is happening because you can only scroll up so much on MD until it says "Check your phone for older messages"

The while loop keeps going because there are earler messages but it doesn't end because the MD session refuses to actually load any more messages.

blackchineykh commented 2 years ago

Would this affect buttons sending as well @smashah? I have situations where the buttons are not being consistently sent as seen below. As you can see it just shows the timer icon

image

image

smashah commented 2 years ago

@github-actions run

⚡ Release! ⚡ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } //set the version type process.env.VERS = "patch" // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i -D`); exec(`npm run release-ci $VERS`); // types only package exec('npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN') exec(`cd ./types-only && npm version $VERS && npm run build && npm publish && cd ..`); exec(`git commit -a -m 'updated types-only package'`); exec(`git push --force`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 2 years ago

Changelog

🚀 Release 4.35.12 (2022-04-28)

nabil-cpu commented 2 years ago

@blackchineykh @smashah can you help me how do you make the button as drawn? WhatsApp Image 2022-04-26 at 22 48 52 is it true that the code is like that? if you ask multidevice i've changed it to true image if you don't mind can you make the code, thank you

smashah commented 2 years ago

@nabil-cpu @blackchineykh please use

console.log("________BUTTON TEST__________")
const buttonDebug = await client.testButtons(chatId)
console.log(buttonDebug)

Try the above code in a personal chat, a group chat and a different personal chat. Isolate the session so there's no unnecessary noise in the logs. Keep doing it until the recipient devices successfully receive the buttons. Then compile and compare the failed buttons with the successful buttons.

Then share a pastebin of all of the logs including launch logs with me on discord (there's sensitive information in those logs).

This is one of the hardest issue I've had to debug on this project so far due to its inconsistency and lack of explicit errors so I need your cooperation if you want this to be resolved.

tinyCoder32 commented 2 years ago

Hi there, I've tried sending buttons and lists to multiple group chats, it never worked until I send a text message to these groups first, then sending the buttons/lists after that works without a problem.

Note: I get a successful response with a message ID from the request, but it is not being sent.

I'm on MD/Business.

blackchineykh commented 2 years ago

@nabil-cpu @blackchineykh please use

console.log("________BUTTON TEST__________")
const buttonDebug = await client.testButtons(chatId)
console.log(buttonDebug)

Try the above code in a personal chat, a group chat and a different personal chat. Isolate the session so there's no unnecessary noise in the logs. Keep doing it until the recipient devices successfully receive the buttons. Then compile and compare the failed buttons with the successful buttons.

Then share a pastebin of all of the logs including launch logs with me on discord (there's sensitive information in those logs).

This is one of the hardest issue I've had to debug on this project so far due to its inconsistency and lack of explicit errors so I need your cooperation if you want this to be resolved.

I havent had a chance to run these tests as yet because buttons started working again and I didnt interrupt it but ill test these on my personal account soon. Recently I noticed that it stopped working again and this time its throwing an error as seen below. Is there some patch for this?

 Error: Evaluation failed: TypeError: mmrrf(...) is not a function
    at eval (eval at <anonymous> (:1:10), <anonymous>:1:91914)
    at Array.map (<anonymous>)
    at eval (eval at <anonymous> (:1:10), <anonymous>:1:91805)
    at ExecutionContext._evaluateInternal (/app/node_modules/puppeteer/lib/ExecutionContext.js:102:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async ExecutionContext.evaluate (/app/node_modules/puppeteer/lib/ExecutionContext.js:33:16)
  -- ASYNC --
    at ExecutionContext.<anonymous> (/app/node_modules/puppeteer/lib/helper.js:94:19)
    at DOMWorld.evaluate (/app/node_modules/puppeteer/lib/DOMWorld.js:89:24)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
  -- ASYNC --
    at Frame.<anonymous> (/app/node_modules/puppeteer/lib/helper.js:94:19)
    at Page.evaluate (/app/node_modules/puppeteer/lib/Page.js:591:14)
    at Page.<anonymous> (/app/node_modules/puppeteer/lib/helper.js:95:27)
    at Client.<anonymous> (/app/node_modules/@open-wa/wa-automate/dist/api/Client.js:486:42)
    at Generator.next (<anonymous>)
    at /app/node_modules/@open-wa/wa-automate/dist/api/Client.js:27:71
    at new Promise (<anonymous>)
    at __awaiter (/app/node_modules/@open-wa/wa-automate/dist/api/Client.js:23:12)
    at Client.pup (/app/node_modules/@open-wa/wa-automate/dist/api/Client.js:442:16)
    at Client.<anonymous> (/app/node_modules/@open-wa/wa-automate/dist/api/Client.js:1285:31)
  -- ASYNC --
    at Page.<anonymous> (/app/node_modules/puppeteer/lib/helper.js:94:19)
    at Client.<anonymous> (/app/node_modules/@open-wa/wa-automate/dist/api/Client.js:486:42)
    at Generator.next (<anonymous>)
    at /app/node_modules/@open-wa/wa-automate/dist/api/Client.js:27:71
    at new Promise (<anonymous>)
    at __awaiter (/app/node_modules/@open-wa/wa-automate/dist/api/Client.js:23:12)
    at Client.pup (/app/node_modules/@open-wa/wa-automate/dist/api/Client.js:442:16)
    at Client.<anonymous> (/app/node_modules/@open-wa/wa-automate/dist/api/Client.js:1285:31)
    at Generator.next (<anonymous>)
    at /app/node_modules/@open-wa/wa-automate/dist/api/Client.js:27:71
smashah commented 2 years ago

@blackchineykh seems to be an impossible temporary glitch.

I've updated MD button code. Hopefully buttons are more consistent now. The actuality is that internal MD code is being updated every week or so. It's not very stable.

smashah commented 2 years ago

@blackchineykh I hope the patches have resolved this issue.

Please ping me on discord or update here if this is still happening.

Thanks, closing.