open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!

Home Page:https://docs.openwa.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App dies after the first message

arthurd2 opened this issue · comments

Are you using the latest version of the library?

  • I have checked and am 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

EASY API/CLI

Current Behavior

After QR code authentication, the app works, waiting for a message.
After this first message it dies complaining about an calling a FN variable which is not a function.
(image attached)

Expected Behavior

receive and print messages on the console

Steps To Reproduce

  • with WA 4.71.13, run
const wa = require('@open-wa/wa-automate');
const sessionDataPath = process.env.PATH_SESSION ? process.env.PATH_SESSION : './' ;
wa.create({
    useChrome: true,
    sessionId: "WhatsAppTranscription",
    multiDevice: true, //required to enable multiDevice support
    authTimeout: 30, //wait only 60 seconds to get a connection with the host account device
    blockCrashLogs: true,
    disableSpins: true,
    headless: true,
    hostNotificationLang: 'PT_BR',
    logConsole: true,
    popup: true,
    qrTimeout: 300, //0 means it will wait forever for you to scan the qr code
    sessionDataPath,
}).then( client => { client.onAnyMessage( processMessage() )} );


async function processMessage( message ){
    if ( message ) { console.log( message ); }
}

create() code OR full CLI command + CONFIG

No response

DEBUG INFO

{
  "WA_VERSION": "2.3000.1014402616",
  "WA_AUTOMATE_VERSION": "4.71.13",
  "BROWSER_VERSION": "HeadlessChrome/125.0.6422.141",
  "START_TS": 1719027152752,
  "RAM_INFO": "Total: 33.42 GB | Free: 2.50 GB",
  "PPTR_VERSION": "19.11.1",
  "LATEST_VERSION": true,
  "CLI": false,
  "PATCH_HASH": "e4663",
  "LAUNCH_TIME_MS": 10420,
  "ACC_TYPE": "PERSONAL",
  "chats": 1153,
  "messages": 143,
  "contacts": 16565,
  "isBiz": false,
  "isMd": true,
  "INSTANCE_ID": "330dd469-92b8-444e-a193-7ddd2b892b22"
}

Environment

- OS: Linux 6.5
- Node: 22.2.0
- npm: 10.8.1

Screenshots/Logs

image

Anything else?

No response

On create() I've replaced the:

.then( client => { client.onAnyMessage( processMessage(message,client)) )} );

for

.then(client => start(client));
async function start(client) {
    client.onAnyMessage(async message => processMessage(message,client) )
}