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

Farewell, Webpack! Re-injection, Pairing Code login, and 2.24x jumbofix #2816

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

PurpShell
Copy link
Sponsor Collaborator

@PurpShell PurpShell commented Mar 14, 2024

Support my work on GitHub Sponsors

TL;DR:

WhatsApp released 2.3000x, a version that does not use Webpack anymore. We had to change the Store system to no longer use moduleRaid. Instability issues are caused by relying on selectors & DOM Observers for login, as well as increased performance issues. This prompted me to adopt the "New startup flow" that I mentioned here. This update is important. This update will boost reliability in WWebJS at least 400%. I also added pairing code login for those who needed it since I had the docs on hand (I reverse engineer then take notes, so I know what I know when I make them into PRs). It changes a lot in the authentication and launching. I advise you all to test your systems before deploying to production (even though this build should be prod-safe).

You should immediately update to my version and cease using any other fork or version. Your system will work regardless if you are using a web cache, local cache, no cache.. LocalAuth, RemoteAuth, NoAuth... 2.24 and 2.3000.

TO INSTALL:

npm install github:pedroslopez/whatsapp-web.js#webpack-exodus

If you encounter a git not found error in the NPM/yarn install: Download git, https://git-scm.com

Thank you for your trust and time and thank you to my sponsors for their contribution.

PR Details

This PR adds support for Wwebjs past version 2.3000.x and 2.24..x. Send "F" in the chat for Webpack!

As always, very big thanks to my sponsors for their support! I am only able to do this thanks to them!

Also thanks to @allburov for his work on #2827, helped me a bit to know which modules are problematic.

This PR also adds re-injection in the case of navigation or refresh or intentional logout and pairing code login option.

It also changes a lot of the code in the startup flow.

To note:

  1. AUTHENTICATED and READY will now depend on the Socket, so if the WWebJS restarts or loses Internet, it will trigger these events. Do not trust that the event will only be triggered once.
  2. await client.initialize() returns it promise much earlier at the point of a new QR code (no login). The behavior is almost the same when logged in (it resolves the promise at AROUND ready).
  3. The Loading screen text will be hard-coded to "WhatsApp" for now. A new update will deprecate this screen text and replace it with loading types (ORGANIZING, INTIAL_LOAD, DOWNLOADING,...)
  4. A new AuthStore is exposed at the time of initial load (before READY) including moduleRaid (2.24) and some modules needed for authentication.

This update will bring a lot of performance, time savings and increased reliability due to this refactor. We are not relying on constantly changing and dynamic HTML to get QR codes, to detect logins and this will make it much better. I also went out of my way and reversed all of the Pairing Code infra to get the only needed functions (3) and made them into this way so that we stop getting failed attempts like #2363

Description

Related Issue

closes #2789, closes #1787, closes #3016

Motivation and Context

After WhatsApp's update to 2.3000.x, moduleRaid no longer detected webpack (since they changed build systems)
After WhatsApp's update to 2.24xx.x, the manifest json no longer included the version, requiring a revamp for the cache system!

How Has This Been Tested

I tested this on many machines and concluded it is non-obtrusive. This will not break old versions and works with new ones

Types of changes

  • Dependency change
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • I have updated the documentation accordingly (index.d.ts).

@ricardoapaes
Copy link
Contributor

Good morning, but it's not running here because it doesn't find this require "__debug", how do I solve it?

image

@complanboy2
Copy link

Also, the "eval" function from inject.js file isn't running due to content security policy !!

@Shinhwe
Copy link

Shinhwe commented Mar 15, 2024

Good morning, but it's not running here because it doesn't find this require "__debug", how do I solve it?

image

try this
Object.values(window.require('__debug').modulesMap

@PurpShell PurpShell marked this pull request as draft March 16, 2024 15:25
@PurpShell
Copy link
Sponsor Collaborator Author

Good morning, but it's not running here because it doesn't find this require "__debug", how do I solve it?

image

Check the latest moduleRaid version

@PurpShell
Copy link
Sponsor Collaborator Author

Good morning, but it's not running here because it doesn't find this require "__debug", how do I solve it?
image

try this Object.values(window.require('__debug').modulesMap

pretty sure I did that, I will see if I didn't

@voidpack
Copy link

voidpack commented Mar 17, 2024

using nodejs v13 after apply new moduleraid on whatsapp web version Version 2.3000.1012111500 still got error

(node:10784) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')

@MoudiZd
Copy link

MoudiZd commented Mar 17, 2024

using nodejs v13 after apply new moduleraid on whatsapp web version Version 2.3000.1012111500 still got error

(node:10784) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')

I believe that the issue is not in the pr itself but in the way moduleRaid is used and the way is finding modules, used within injected.js, because in many cases it assumes that the findModule method returns non empty array, maybe with old webpack this way it was feasible but now with comet this code needs some optimization

I am not sure if the manipulation of these statements actually differs between node versions or between different modes, this need a lot of tests

@complanboy2
Copy link

ModuleError: Requiring module "%s" with unresolved dependencies: %s

Getting this error

@MoudiZd
Copy link

MoudiZd commented Mar 17, 2024

ModuleError: Requiring module "%s" with unresolved dependencies: %s

Getting this error

Please if you can print the full error so we can see in which file and in which line this error is occured

@complanboy2
Copy link

complanboy2 commented Mar 17, 2024

ModuleError: Requiring module "%s" with unresolved dependencies: %s
Getting this error

Please if you can print the full error so we can see in which file and in which line this error is occured

Thank you. I'm using module raid and the code from inject.js

@voidpack
Copy link

using nodejs v13 after apply new moduleraid on whatsapp web version Version 2.3000.1012111500 still got error
(node:10784) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')

I believe that the issue is not in the pr itself but in the way moduleRaid is used and the way is finding modules, used within injected.js, because in many cases it assumes that the findModule method returns non empty array, maybe with old webpack this way it was feasible but now with comet this code needs some optimization

I am not sure if the manipulation of these statements actually differs between node versions or between different modes, this need a lot of tests

maybe because i'm using backtick for this on module raid ? because without backtick it give error unexpected token '.' on nodejs v13

const isComet = parseInt(window.Debug?.VERSION?.split(".")?.[1]) >= 3000;

@mouhammad-zd
Copy link

mouhammad-zd commented Mar 17, 2024

using nodejs v13 after apply new moduleraid on whatsapp web version Version 2.3000.1012111500 still got error
(node:10784) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')

I believe that the issue is not in the pr itself but in the way moduleRaid is used and the way is finding modules, used within injected.js, because in many cases it assumes that the findModule method returns non empty array, maybe with old webpack this way it was feasible but now with comet this code needs some optimization
I am not sure if the manipulation of these statements actually differs between node versions or between different modes, this need a lot of tests

maybe because i'm using backtick for this on module raid ? because without backtick it give error unexpected token '.' on nodejs v13

const isComet = parseInt(window.Debug?.VERSION?.split(".")?.[1]) >= 3000;

Try to update your node version, as it seems that optional chaining is not supported in node older than node 14

@voidpack
Copy link

using nodejs v13 after apply new moduleraid on whatsapp web version Version 2.3000.1012111500 still got error
(node:10784) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')

I believe that the issue is not in the pr itself but in the way moduleRaid is used and the way is finding modules, used within injected.js, because in many cases it assumes that the findModule method returns non empty array, maybe with old webpack this way it was feasible but now with comet this code needs some optimization
I am not sure if the manipulation of these statements actually differs between node versions or between different modes, this need a lot of tests

maybe because i'm using backtick for this on module raid ? because without backtick it give error unexpected token '.' on nodejs v13
const isComet = parseInt(window.Debug?.VERSION?.split(".")?.[1]) >= 3000;

Try to update your node version, as it seems that optional chaining is not supported in node older than node 14

can't do it. because the client still using windows 7. latest support can only using node v13

@MoudiZd
Copy link

MoudiZd commented Mar 17, 2024

You must optimize code to use old javascript

using nodejs v13 after apply new moduleraid on whatsapp web version Version 2.3000.1012111500 still got error
(node:10784) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')

I believe that the issue is not in the pr itself but in the way moduleRaid is used and the way is finding modules, used within injected.js, because in many cases it assumes that the findModule method returns non empty array, maybe with old webpack this way it was feasible but now with comet this code needs some optimization
I am not sure if the manipulation of these statements actually differs between node versions or between different modes, this need a lot of tests

maybe because i'm using backtick for this on module raid ? because without backtick it give error unexpected token '.' on nodejs v13
const isComet = parseInt(window.Debug?.VERSION?.split(".")?.[1]) >= 3000;

Try to update your node version, as it seems that optional chaining is not supported in node older than node 14

can't do it. because the client still using windows 7. latest support can only using node v13

So you must optimize this statement to use old javascript

Try this:

var isComet = false;

if (window.Debug && window.Debug.VERSION) {
  var versionParts = window.Debug.VERSION.split(".");
  if (versionParts.length > 1) {
    var versionNumber = parseInt(versionParts[1]);
    isComet = versionNumber >= 3000;
  }
}

@maunklana
Copy link

maunklana commented Mar 18, 2024

I got this error

C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
    at __puppeteer_evaluation_script__:5:95
    at ExecutionContext._evaluateInternal (C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async Client.initialize (C:\Users\Maunklana\Documents\ww\node_modules\whatsapp-web.js\src\Client.js:339:9)

Node.js v20.9.0

the error was caused by a change in the function

image

so I change the injected.js remove all .default

window.Store = Object.assign({}, window.mR.findModule(m => m && m.Chat)[1]);
window.Store.Call = window.mR.findModule((module) => module && module.Call)[0].Call;

Tested Sending & Receive Message is ok.

Update
Got this Error on Sending message on some text or something.

Error: Evaluation failed: Error: Data passed to getter must include an id property (it's how we memoize) but got undefined
	at new Error (<anonymous>:5:31)
	at h (https://static.whatsapp.net/rsrc.php/v3/yO/r/rP20sdRimEJ.js?_nc_x=Ij3Wp8lg5Kz:70:191)
	at t (https://static.whatsapp.net/rsrc.php/v3iex14/yT/l/makehaste_jhash/JjfhzrFnzpi.js?_nc_x=Ij3Wp8lg5Kz:391:4493)
	at Object.d [as getLinkPreview] (https://static.whatsapp.net/rsrc.php/v3iex14/yT/l/makehaste_jhash/JjfhzrFnzpi.js?_nc_x=Ij3Wp8lg5Kz:391:2447)
	at window.WWebJS.sendMessage (__puppeteer_evaluation_script__:135:62)
	at async __puppeteer_evaluation_script__:10:25
	at ExecutionContext._evaluateInternal (C:\Users\Maunklana\Documents\ww\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
	at process.processTicksAndRejections (node:internal\process\task_queues:95:5)
	at async ExecutionContext.evaluate (C:\Users\Maunklana\Documents\ww\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
	at async Client.sendMessage (C:\Users\Maunklana\Documents\ww\node_modules\whatsapp-web.js\src\Client.js:930:28)

@voidpack
Copy link

I got this error

C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
    at __puppeteer_evaluation_script__:5:95
    at ExecutionContext._evaluateInternal (C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async Client.initialize (C:\Users\Maunklana\Documents\ww\node_modules\whatsapp-web.js\src\Client.js:339:9)

Node.js v20.9.0

the error was caused by a change in the function

image

so I change the injected.js remove all .default

window.Store = Object.assign({}, window.mR.findModule(m => m && m.Chat)[1]); window.Store.Call = window.mR.findModule((module) => module && module.Call)[0].Call;

Tested Sending & Receive Message is ok.

i try remove that 2 line .default still error reading 'default'
and then i try remove all the .default on injected and got error reading 'on'

using node v13 and whatsapp web Version 2.3000.1012116664 (did your web version like mine ? i found that after 2.3000.xxxxx the number xxxxx keep increasing, maybe whatsapp keep updating or what ?)

@maunklana
Copy link

try following this change #2822

I got this error

C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
    at __puppeteer_evaluation_script__:5:95
    at ExecutionContext._evaluateInternal (C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async Client.initialize (C:\Users\Maunklana\Documents\ww\node_modules\whatsapp-web.js\src\Client.js:339:9)

Node.js v20.9.0

the error was caused by a change in the function
image
so I change the injected.js remove all .default
window.Store = Object.assign({}, window.mR.findModule(m => m && m.Chat)[1]); window.Store.Call = window.mR.findModule((module) => module && module.Call)[0].Call;
Tested Sending & Receive Message is ok.

i try remove that 2 line .default still error reading 'default' and then i try remove all the .default on injected and got error reading 'on'

using node v13 and whatsapp web Version 2.3000.1012116664 (did your web version like mine ? i found that after 2.3000.xxxxx the number xxxxx keep increasing, maybe whatsapp keep updating or what ?)

@voidpack
Copy link

try following this change #2822

I got this error

C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
    at __puppeteer_evaluation_script__:5:95
    at ExecutionContext._evaluateInternal (C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (C:\Users\Maunklana\Documents\ww\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async Client.initialize (C:\Users\Maunklana\Documents\ww\node_modules\whatsapp-web.js\src\Client.js:339:9)

Node.js v20.9.0

the error was caused by a change in the function
image
so I change the injected.js remove all .default
window.Store = Object.assign({}, window.mR.findModule(m => m && m.Chat)[1]); window.Store.Call = window.mR.findModule((module) => module && module.Call)[0].Call;
Tested Sending & Receive Message is ok.

i try remove that 2 line .default still error reading 'default' and then i try remove all the .default on injected and got error reading 'on'
using node v13 and whatsapp web Version 2.3000.1012116664 (did your web version like mine ? i found that after 2.3000.xxxxx the number xxxxx keep increasing, maybe whatsapp keep updating or what ?)

thx finally fix it. I miss the array [0] change to [1]. thx you very much

@maunklana maunklana mentioned this pull request Mar 19, 2024
6 tasks
@neb6la neb6la mentioned this pull request Mar 21, 2024
1 task
@Abhii-Agarwal09

This comment was marked as off-topic.

@MoudiZd MoudiZd mentioned this pull request Mar 31, 2024
1 task
@PurpShell PurpShell changed the title Farewell, Webpack! Farewell, Webpack! Also, patch for 2.24**!! Apr 2, 2024
@PurpShell PurpShell changed the title Farewell, Webpack! Also, patch for 2.24**!! Farewell, Webpack! Also, patch for 2.24xx.x!! Apr 3, 2024
@PurpShell PurpShell marked this pull request as ready for review April 3, 2024 00:53
@ozkanydin
Copy link

I tried everything but I still get this error TypeError: Cannot read properties of undefined (reading 'default'). Is there a solution? I am using the new whatsapp web.js 1.24. Please help me

@alechkos alechkos mentioned this pull request Jun 29, 2024
1 task
@danyllo106
Copy link

@ozkanydin , try this:

webVersionCache: {
type: "remote",
remotePath: "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2413.51-beta.html",
},

I'm using the vesion
"whatsapp-web.js": "^1.24.0"

But I couldn't solve the video sending problem in this version

@ozkanydin
Copy link

thanks for the reply @danyllo106

I'm getting this error. Do you have a solution this time? Can you help me? I've been trying for days.

    throw new Error('Evaluation failed: ' + (0, util_js_1.getExceptionMessage)(exceptionDetails));
          ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading '_find')
at pptr://puppeteer_evaluation_script:96:28

@danyllo106
Copy link

thanks for the reply @danyllo106

I'm getting this error. Do you have a solution this time? Can you help me? I've been trying for days.

    throw new Error('Evaluation failed: ' + (0, util_js_1.getExceptionMessage)(exceptionDetails));
          ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading '_find') at pptr://puppeteer_evaluation_script:96:28

Have you tried uninstalling node_modules from the project, .wwebjs_auth and .wwebjs_cache
and give a npm install?

@ozkanydin
Copy link

@danyllo106
Yes, when I encountered the error, I made them directly, my puppeteer version etc. Could there be a problem with this?
package.json like this:
{
"name": "whatsapp-web.js",
"version": "1.24.0",
"description": "Library for interacting with the WhatsApp Web API",
"main": "./index.js",
"typings": "./index.d.ts",
"scripts": {
"test": "mocha tests --recursive --timeout 5000",
"test-single": "mocha",
"shell": "node --experimental-repl-await ./shell.js",
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pedroslopez/whatsapp-web.js.git"
},
"keywords": [
"whatsapp",
"whatsapp-web",
"api",
"boots",
"client",
"node"
],
"author": "Pedro Lopez",
"license": "apache-2.0",
"bugs": {
"url": "https://github.com/pedroslopez/whatsapp-web.js/issues"
},
"homepage": "https://wwebjs.dev/",
"dependencies": {
"@pedroslopez/moduleraid": "^5.0.2",
"fluent-ffmpeg": "2.1.2",
"mime": "^3.0.0",
"node-fetch": "^2.6.9",
"node-webpmux": "3.1.7",
"puppeteer": "^18.2.1"
},
"devDependencies": {
"@types/node-fetch": "^2.5.12",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"dotenv": "^16.0.0",
"eslint": "^8.4.1",
"eslint-plugin-mocha": "^10.0.3",
"jsdoc": "^3.6.4",
"jsdoc-baseline": "^0.1.5",
"mocha": "^9.0.2",
"sinon": "^13.0.1"
},
"engines": {
"node": ">=18.0.0"
},
"optionalDependencies": {
"archiver": "^5.3.1",
"fs-extra": "^10.1.0",
"unzipper": "^0.10.11"
}
}

@DiegoFelipe
Copy link

hi it solves this problem: "Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'push')" but it doesn't make the application work! it can't start WhatsApp, there's no auth message anymore it doesn't show anything

@RuslanAmraev
Copy link

RuslanAmraev commented Jun 29, 2024

But how can I use methods from the channel pull? I need to send a message into the WhatsApp channel.

@GustavoChaconDeveloper
Copy link

Oi, sobre os erros que estão acontecendo na hora de escanear o QR code e em seguida aparecer o erro:

C:\wamp64\www\testebot\node_modules\puppeteer\lib\cjs\puppeteer\common\Execution
Context.js:221
throw new Error('Evaluation failed: ' + helper_js_1.helper.getExcept
ionMessage(exceptionDetails));
^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (readin
g 'push')
at fillModuleArray (eval at (:2:5), :6:74)
at moduleRaid (eval at (:2:5), :15:3)
at puppeteer_evaluation_script:4:17
at ExecutionContext._evaluateInternal (C:\wamp64\www\testebot\node_modules\p
uppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5
)
at async ExecutionContext.evaluate (C:\wamp64\www\testebot\node_modules\pupp
eteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
at async Client.initialize (C:\wamp64\www\testebot\node_modules\whatsapp-web
.js\src\Client.js:339:9)

Consegui resolver mudando no arquivo node_modules@pedroslopez\moduleraid\moduleraid.js a linha do fillModuleArray:

fillModuleArray = function() {
(window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([
[moduleRaid.mID], {}, function(e) {
Object.keys(e.m).forEach(function(mod) {
moduleRaid.mObj[mod] = e(mod);
})
}
]);
}

fillModuleArray();

Para essta:

fillModuleArray = function() {
if (parseFloat(window.Debug.VERSION) < 2.3) {
(window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([
[moduleRaid.mID], {}, function(e) {
Object.keys(e.m).forEach(function(mod) {
moduleRaid.mObj[mod] = e(mod);
})
}
]);
} else {
let modules = self.require('__debug').modulesMap;
Object.keys(modules).filter(e => e.includes("WA")).forEach(function (mod) {
let modulos = modules[mod];
if (modulos) {
moduleRaid.mObj[mod] = {
default: modulos.defaultExport,
factory: modulos.factory,
...modulos
};
if (Object.keys(moduleRaid.mObj[mod].default).length == 0) {
try {
self.ErrorGuard.skipGuardGlobal(true);
Object.assign(moduleRaid.mObj[mod], self.importNamespace(mod));
} catch (e) {
}
}
}
})
}
}

fillModuleArray();

@LeonLej
Copy link

LeonLej commented Jun 30, 2024

Oi, sobre os erros que estão acontecendo na hora de escanear o QR code e em seguida aparecer o erro:

C:\wamp64\www\testebot\node_modules\puppeteer\lib\cjs\puppeteer\common\Execution Context.js:221 throw new Error('Evaluation failed: ' + helper_js_1.helper.getExcept ionMessage(exceptionDetails)); ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (readin g 'push') at fillModuleArray (eval at (:2:5), :6:74) at moduleRaid (eval at (:2:5), :15:3) at puppeteer_evaluation_script:4:17 at ExecutionContext._evaluateInternal (C:\wamp64\www\testebot\node_modules\p uppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5 ) at async ExecutionContext.evaluate (C:\wamp64\www\testebot\node_modules\pupp eteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16) at async Client.initialize (C:\wamp64\www\testebot\node_modules\whatsapp-web .js\src\Client.js:339:9)

Consegui resolver mudando no arquivo node_modules@pedroslopez\moduleraid\moduleraid.js a linha do fillModuleArray:

fillModuleArray = function() { (window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([ [moduleRaid.mID], {}, function(e) { Object.keys(e.m).forEach(function(mod) { moduleRaid.mObj[mod] = e(mod); }) } ]); }

fillModuleArray();

Para essta:

fillModuleArray = function() { if (parseFloat(window.Debug.VERSION) < 2.3) { (window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([ [moduleRaid.mID], {}, function(e) { Object.keys(e.m).forEach(function(mod) { moduleRaid.mObj[mod] = e(mod); }) } ]); } else { let modules = self.require('__debug').modulesMap; Object.keys(modules).filter(e => e.includes("WA")).forEach(function (mod) { let modulos = modules[mod]; if (modulos) { moduleRaid.mObj[mod] = { default: modulos.defaultExport, factory: modulos.factory, ...modulos }; if (Object.keys(moduleRaid.mObj[mod].default).length == 0) { try { self.ErrorGuard.skipGuardGlobal(true); Object.assign(moduleRaid.mObj[mod], self.importNamespace(mod)); } catch (e) { } } } }) } }

fillModuleArray();

It worked for me, but when I reply to a message or receive a call, for example, I get the following error:

node:internal/process/promises:391
error al responder
error al responder

triggerUncaughtException(err, true /* fromPromise */);
^

Error: Data passed to getter must include an id property (it's how we memoize) but got undefined
new Error (:5:31)
at window.WWebJS.sendMessage (evaluate at Client.initialize ←[90m(C:\EnvioWhatsAppV26\←[39msrc\Client.js:361:20), :134:61←[90m)←[39m
at #evaluate ←[90m(C:\EnvioWhatsAppV26\←[39mnode_modules\←[4mpuppeteer-core←[24m\lib\cjs\puppeteer\cdp\ExecutionContext.js:376:56←[90m)←[39m
at async ExecutionContext.evaluate ←[90m(C:\EnvioWhatsAppV26\←[39mnode_modules\←[4mpuppeteer-core←[24m\lib\cjs\puppeteer\cdp\ExecutionContext.js:271:16←[90m)←[39m

@FelipeJz
Copy link

I still get this error mentioned in #3100 once in a while.

Evaluation failed: TypeError: Cannot read properties of undefined (reading 'WidFactory')
'WidFactory')
2024-06-30T21:28:08.797153139Z     at pptr://__puppeteer_evaluation_script__:2:42
2024-06-30T21:28:08.797158115Z     at ExecutionContext._ExecutionContext_evaluate (/app/node_modules/puppeteer-core/src/common/ExecutionContext.ts:294:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ExecutionContext.evaluate (/app/node_modules/puppeteer-core/src/common/ExecutionContext.ts:137:12)
at async Client.sendMessage (/app/node_modules/whatsapp-web.js/src/Client.js:932:28)

@najamrehman
Copy link

remotepath: ...wppconnect-team/wa-version/main/html/2.2413.51-beta.html" not found,

What is the alternative ?

@micjef
Copy link

micjef commented Jul 1, 2024

remotepath: ...wppconnect-team/wa-version/main/html/2.2413.51-beta.html" not found,

What is the alternative ?

im have same problem, any solution ?

@calvin-kargo
Copy link

it

remotepath: ...wppconnect-team/wa-version/main/html/2.2413.51-beta.html" not found,

What is the alternative ?

it seems all of the old & compatible version of whatsapp has been removed from wppconnect github at https://github.com/wppconnect-team/wa-version/tree/main/html . you can access the old html content on previous git version (like following https://raw.githubusercontent.com/wppconnect-team/wa-version/601b90a9fffce8a19e08efba9bd804fdcb43f656/html/2.2412.54.html ) but on my server it seems whatsapp has deactivated all of old whatsapp web version. i am currently trying out the bleeding edge library version (npm install github:pedroslopez/whatsapp-web.js#webpack-exodus)

@Vedeneb
Copy link

Vedeneb commented Jul 1, 2024

I'm already using github:pedroslopez/whatsapp-web.js#webpack-exodus but I still get Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default') since tonight, right after scanning the QR code (same es #3156).

What am I doing wrong?

Repository owner locked as too heated and limited conversation to collaborators Jul 1, 2024
hivansan referenced this pull request in wppconnect-team/wa-version Jul 1, 2024
@tuyuribr
Copy link
Collaborator

tuyuribr commented Jul 2, 2024

Thanks to @rbkayz for helping with the createGroup newFunction

@alechkos
Copy link
Collaborator

alechkos commented Jul 2, 2024

WWeb v2.24.xx left the cycle, use this branch until it is merged or another solution is provided

To migrate to WWeb v2.3000.x do these steps:

1. If you have .wwebjs_auth folder in the root project directory:

  • Remove .wwebjs_auth folder
  • Terminate your linked bot session in the mobile device

2. npm i github:pedroslopez/whatsapp-web.js#webpack-exodus

The initial client setup example (click here to expand):

const { Client, LocalAuth } = require('whatsapp-web.js');
const qrcode = require('qrcode-terminal');

const client = new Client({
    authStrategy: new LocalAuth(),
    restartOnAuthFail: true,
    puppeteer: {
        headless: true,
        args: [/* your args here */]
    }
});

client.on('qr', qr => {
    qrcode.generate(qr, { small: true });
});

client.on('authenticated', () => {
    console.log('AUTHENTICATED');
});

client.on('ready', async () => {
    const version = await client.getWWebVersion();
    console.log(`WWeb v${version}`);
});

client.initialize();

Note

Don't use webVersionCache

3. Start the bot


For more information, check the guide

If you have questions, ask them in Discrod

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking change Fix or feature that would cause existing functionality to change waiting for testers Waiting for other people test this PR in other envs
Projects
None yet