await Client.getAmountOfLoadedMessages() returns error "Error [TypeError]: Cannot read properties of undefined (reading 'length')"
TVARecordings 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
Script is unable to read the .length of const LoadedMessages = await Client.getAmountOfLoadedMessages()
It returns this error:
Error [TypeError]: Cannot read properties of undefined (reading 'length')
at window.WAPI.getAmountOfLoadedMessages (evaluate at E:\AmecaCore\node_modules@open-wa\wa-automate\dist\controllers\browser.js:379:94, :2065:28)
at evaluate (evaluate at Client. (E:\AmecaCore\node_modules@open-wa\wa-automate\dist\api\Client.js:565:44), :0:12)
at #evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:222:56)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ExecutionContext.evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:117:16)
at async IsolatedWorld.evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\IsolatedWorld.js:124:16)
at async CdpFrame.evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\api\Frame.js:343:20)
at async CdpPage.evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\api\Page.js:828:20)
Code:
const LoadedMessages = await Client.getAmountOfLoadedMessages()
conLog(`A total of ${LoadedMessages} messages are in cache. `)
if (LoadedMessages >= 1000) {
announce(`Cutting Message Cache, there were ${LoadedMessages} loaded message in cache.`)
const newLoadedMessages = await Client.cutMsgCache()
announce(`Cutted Message Cache (${LoadedMessages}), amount of loaded message now: ${newLoadedMessages}`)
} else {
announce(`Amount of loaded messages: ${LoadedMessages}`)
}
Expected Behavior
Expected to be able the length.
Steps To Reproduce
Run const LoadedMessages = await Client.getAmountOfLoadedMessages()
create() code OR full CLI command + CONFIG
const configObject = {
sessionId: 'aName',
authTimeout: 0,
cacheEnabled: true,
useChrome: true,
cachedPatch: true,
devtools: false,
chromiumArgs: ['--no-sandbox'],
disableSpins: true,
headless: false, //new
popup: false,
qrTimeout: 0,
messagePreprocessor: "AUTO_DECRYPT", //"AUTO_DECRYPT","SCRUB"
linkParser: "https://link.openwa.cloud/api",
restartOnCrash: true,
logInternalEvents: false, //ONLY TURN THIS ON IF ASKED TO!
discord: 'Mine',
ezqr: true,
callTimeout: 0, // 600000
licenseKey: "Mine"
screenshotOnInitializationBrowserError: false,
hostNotificationLang: 'nl-nl',
killProcessOnBrowserClose: true,
killProcessOnTimeout: false,
logConsole: false,
logConsoleErrors: true,
logFile: true,
onError: "LOG_AND_FALSE",
};
DEBUG INFO
{
"WA_VERSION": "2.3000.1012612339",
"WA_AUTOMATE_VERSION": "4.71.1",
"BROWSER_VERSION": "Chrome/123.0.6312.106",
"START_TS": 1712602829615,
"RAM_INFO": "Total: 68.62 GB | Free: 45.03 GB",
"PPTR_VERSION": "19.11.1",
"LATEST_VERSION": true,
"CLI": false,
"PATCH_HASH": "CACHED-bff5f",
"LAUNCH_TIME_MS": 7010,
"ACC_TYPE": "BUSINESS",
"chats": 338,
"messages": 389,
"contacts": 2633,
"isBiz": true,
"isMd": true,
"INSTANCE_ID": "775e06c7-7b4b-412a-91dd-bf8df0327a3e"
}
Environment
- OS: Windows 10
- Node: 20.11.1
- npm: 10.2.4
Screenshots/Logs
No response
Anything else?
Thanks for the hard work :-)