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 during health check evaluation #3218

Open
1 task done
sword-fish333 opened this issue Jun 10, 2024 · 8 comments
Open
1 task done

Error during health check evaluation #3218

sword-fish333 opened this issue Jun 10, 2024 · 8 comments

Comments

@sword-fish333
Copy link

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

when client.healthCheck().then(... is run an exception is thrown.
Error during health check evaluation: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'length')
at window.. (pptr://puppeteer_evaluation_script:1:361038)
at pptr://puppeteer_evaluation_script:6:28
.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js:258
throw new Error('Evaluation failed: ' + (0, util_js_1.getExceptionMessage)(exceptionDetails));
^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'length')
at window.. (pptr://puppeteer_evaluation_script:1:361038)
at pptr://puppeteer_evaluation_script:6:28
at ExecutionContext._ExecutionContext_evaluate (.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js:258:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ExecutionContext.evaluate (..../node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js:146:16)
apears to be in @open-wa/wa-automate/dist/api/Client.js
this function
healthCheck() {
return __awaiter(this, void 0, void 0, function* () {
return yield this._page.evaluate(() => WAPI.healthCheck());
});
} i tried to mitigate the error by changing the function in node_modules, but the healthCheck does not work.
console.log('this._page=',this._page.evaluate);
const result = yield this._page.evaluate(() => {
console.log('wapi=',WAPI); WAPI is not executed.

Expected Behavior

I expect client.healthCheck to run normally. This is my implementation of the function
client.healthCheck().then(function (val) {
console.log("HealthCheck ", val);
if (val.state = wa.STATE.CONNECTED && val.online) {
var request = {
method: 'post',
url: HEARTBEAT_URL,
};
console.log("Will send heartbeat");
axios(request).then(async function(response) {
console.log("heartbeat successfull")
});
} else {
console.log("HealthCheck failed");
}
And this is the setup of the client:
wa.create({
sessionId: "COVID_HELPER",
multiDevice: true, //required to enable multiDevice support
authTimeout: 60, //wait only 60 seconds to get a connection with the host account devi>
blockCrashLogs: true,
disableSpins: true,
headless: true,
hostNotificationLang: 'PT_BR',
logConsole: true,
ezqr: true,
popup: true,
autoRefresh:false,
qrTimeout: 0, //0 means it will wait forever for you to scan the qr code
}).then(client => start(client));

Steps To Reproduce

  1. install "@open-wa/wa-automate": "^4.71.12"
  2. setup the js script
    const wa = require('@open-wa/wa-automate');
    wa.create({
    sessionId: "COVID_HELPER",
    multiDevice: true, //required to enable multiDevice support
    authTimeout: 60, //wait only 60 seconds to get a connection with the host account devi>
    blockCrashLogs: true,
    disableSpins: true,
    headless: true,
    hostNotificationLang: 'PT_BR',
    logConsole: true,
    ezqr: true,
    popup: true,
    autoRefresh:false,
    qrTimeout: 0, //0 means it will wait forever for you to scan the qr code
    }).then(client => start(client));

function start(client) {
console.log("This is the start");

    const sendHeartbeat = function() {

try{

            client.healthCheck().then(function (val) { <-----here it fails
                    console.log("HealthCheck ", val);
                   
            });
    }catch(e){
    console.log('error in sendHeartbeat',e);
    }
}

    setInterval(sendHeartbeat, 1000 * 60); // each minute
    sendHeartbeat(); // sen

}

create() code OR full CLI command + CONFIG

No response

DEBUG INFO

{
  "WA_VERSION": "2.3000.1014092037",
  "WA_AUTOMATE_VERSION": "4.71.12",
  "BROWSER_VERSION": "HeadlessChrome/112.0.5614.0",
  "START_TS": 1718033355687,
  "RAM_INFO": "Total: 4.10 GB | Free: 3.31 GB",
  "PPTR_VERSION": "19.11.1",
  "LATEST_VERSION": true,
  "CLI": false,
  "PATCH_HASH": "81ba5",
  "LAUNCH_TIME_MS": 20459,
  "ACC_TYPE": "BUSINESS",
  "chats": 405,
  "messages": 51,
  "contacts": 1894,
  "isBiz": true,
  "isMd": true,
  "INSTANCE_ID": "f7194158-69dd-470f-b63a-71e4923f6c4e"
}

Environment

- OS: Linux 5.15
- Node: 22.2.0
- npm: 10.7.0

Screenshots/Logs

healthcheck_error

Anything else?

No response

@nrs1022
Copy link

nrs1022 commented Jun 11, 2024

Hi, it seems WA recent update breaks session health checking. Previous versions 4.71.11 and 4.71.10 are affected too.


- Checking session integrity
info: Checking session integrity  {"data":"Checking session integrity","eventName":"STARTUP.session","eventNamespace":"STARTUP","sessionId":"session","timestamp":"2024-06-11T12:08:32.362Z"}
- Session integrity check passed
info: Session integrity check passed  {"data":"Session integrity check passed","eventName":"STARTUP.session","eventNamespace":"STARTUP","sessionId":"session","timestamp":"2024-06-11T12:08:32.366Z"}
info: GET SCRIPT: launch.js 71128 {"timestamp":"2024-06-11T12:08:32.367Z"}
info: Injection Result of launch.js: undefined {"timestamp":"2024-06-11T12:08:33.233Z"}
- Launch inject: 866ms
info: Launch inject: 866ms  {"data":"Launch inject: 866ms","eventName":"STARTUP.session","eventNamespace":"STARTUP","sessionId":"session","timestamp":"2024-06-11T12:08:33.233Z"}
- WAPI Reinjected
info: WAPI Reinjected  {"data":"WAPI Reinjected","eventName":"STARTUP.session","eventNamespace":"STARTUP","sessionId":"session","timestamp":"2024-06-11T12:08:33.233Z"}
- Checking if session is valid
info: Checking if session is valid  {"data":"Checking if session is valid","eventName":"STARTUP.session","eventNamespace":"STARTUP","sessionId":"session","timestamp":"2024-06-11T12:08:33.233Z"}
error: Valid session check failed Waiting failed: 9000ms exceeded  {"name":"TimeoutError","stack":"TimeoutError: Waiting failed: 9000ms exceeded\n    at Timeout.<anonymous> (/home/codewa/.codewa/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:71:32)\n    at listOnTimeout (node:inte...[TRUNCATED]...","timestamp":"2024-06-11T12:08:42.234Z"}
info: Store keys  {"0":"Call","1":"MediaCollection","10":"WapQuery","11":"UserConstructor","12":"SendTextMsgToChat","13":"ReadSeen","14":"sendDelete","15":"addAndSendMsgToChat","16":"Catalog","17":"MsgKey","18":"Parser","19":"Builders","2":"Archive","20":"Me","21":"MyStatus","22":"ChatStates","23":"GroupActions","24":"Participants","25":"WidFactory","26":"Sticker","27":"UploadUtils","3":"Block","4":"ChatUtil","5":"GroupInvite","6":"Wap","7":"State","8":"_Presence","9":"WapDelete","timestamp":"2024-06-11T12:08:42.236Z"}
- The session is invalid. Retrying
info: The session is invalid. Retrying  {"data":"The session is invalid. Retrying","eventName":"STARTUP.session","eventNamespace":"STARTUP","sessionId":"session","timestamp":"2024-06-11T12:08:42.237Z"}
🚀 ~ needsToScan ~ elementResult: undefined

Debug info:

Debug info: {
 "WA_VERSION": "2.3000.1014111620",
 "PAGE_UA": "WhatsApp/2.2147.16 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
 "WA_AUTOMATE_VERSION": "4.71.12",
 "BROWSER_VERSION": "HeadlessChrome/112.0.5614.0",
 "OS": "Linux 6.5",
 "START_TS": 1718107723628,
 "RAM_INFO": "Total: 8.13 GB | Free: 5.61 GB",
 "PPTR_VERSION": "19.11.1"
}

@dalraf
Copy link

dalraf commented Jun 11, 2024

I tried several versions up to 4.71.4 and 4.68.0, the problem continues

@sword-fish333
Copy link
Author

yes, i could not find a solution to the problem, is on backburner in my case.

@smashah
Copy link
Member

smashah commented Jun 11, 2024

thanks for reporting this. fix coming soon, it will require updating

@smashah smashah reopened this Jun 11, 2024
@smashah
Copy link
Member

smashah commented Jun 11, 2024

@github-actions run

⚡ Release! ⚡
(async () => {
function exec(cmd) {
try {
	execSync(cmd, {stdio: 'inherit'})
}  catch (error) {
    console.log(`Status Code: ${error.status} with '${error.message}'`);
 }
}
//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(`npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN && npm run types:publish `);
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
Copy link
Member

smashah commented Jun 11, 2024

Changelog

🚀 Release 4.71.13 (2024-06-11)

@nrs1022
Copy link

nrs1022 commented Jun 11, 2024

Thank you @smashah, it's working now.

@dalraf
Copy link

dalraf commented Jun 11, 2024

Working now Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants