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

Uncaught TypeError: Cannot read properties of undefined (reading 'm') #1778

Closed
DXPRO opened this issue Mar 26, 2024 · 5 comments
Closed

Uncaught TypeError: Cannot read properties of undefined (reading 'm') #1778

DXPRO opened this issue Mar 26, 2024 · 5 comments

Comments

@DXPRO
Copy link
Contributor

DXPRO commented Mar 26, 2024

WA-JS Version

v3.0.1

WhatsApp Version

2.3000.1012314172

Browser Version

Chrome Version 122.0.6261.131

Operation System

Windows 11

Steps to reproduce

1 - Open the browser console connected to WhatsApp web in version 2.3000.x

2 - Inject WA-JS version 3.0.1

3 - Call the WPP.chat.list() await function;

What is expected?

Show WhatsApp Web conversation list

What is actually happening?

Generating the error: Uncaught TypeError: Cannot read properties of undefined (reading 'm')
at Object.p [as searchId] (:12567:58)
at Object.get [as ChatStore] (:13134:45)
at t.list (:6574:31)
at :1:16

This error is caused by the function below:

function p(e, r = !1) {
                    let n = Object.keys(t.webpackRequire.m);
                    r && (n = n.reverse());
                    const o = setTimeout(() => {
                        a(`Searching for: ${e.toString()}`);
                    }, 500);
                    for (const r of n)
                        if (!f(r))
                            try {
                                const n = (0, t.webpackRequire)(r);
                                if (e(n, r)) return a(`Module found: ${r} - ${e.toString()}`), clearTimeout(o), r;
                            } catch (e) {
                                continues;
                            }
                    n = Object.keys(t.fallbackModules);
                    for (const r of n)
                        try {
                            const n = t.fallbackModules[r];
                            if (e(n, r)) return a(`Fallback Module found: ${r} - ${e.toString()}`), clearTimeout(o), r;
                        } catch (e) {
                            continues;
                        }
                    return a(`Module not found: ${e.toString()}`), null;
                }

Any additional comments?

No response

@silemftooh
Copy link

The steps to reproduce the issue are:

  1. Login Whatsapp scanning QR code (whatsapp version > 2.3000)
  2. Manual inject wa js in console (single time)

WPP.isInjected is always False

@opsJson
Copy link
Contributor

opsJson commented Mar 26, 2024

Whatsapp is delivering js that is incompatible with the lib when you have the "wa_build=c" cookie set.

To fix it, set the cookie to any other value, then reload the page:

document.cookie = "wa_build=w;domain=.web.whatsapp.com;path=/";

For me, Whatsapp is setting this cookie every time I reload the page, forcing me to set another value for the cookie every time.

@ono77
Copy link

ono77 commented Mar 26, 2024

the problem seems that in the 2.300 version, the injected code wrongly set the WPP.webpack.loaderType = "webpack" instead of "meta".

Maybe a solution is adding a check of wa web version In the injectLoader function, replacing these lines

, n = "webpackChunkwhatsapp_web_client"
, o = e[n] || [];
 void 0 === e[n] ? e[n] = o : t.loaderType = "webpack";

with

,n="webpackChunkwhatsapp_web_client"
,o=e[n]||[];
const versionString = (Debug || {}).VERSION;
const versionNumber = parseFloat(versionString);
if (void 0 === e[n]) {e[n] = o;} else if (versionNumber < 2.3) { t.loaderType = "webpack";}

@icleitoncosta
Copy link
Contributor

Hello, could you please test this fix I made on the scenarios you've been facing and provide feedback on the PR?

#1783

@silemftooh
Copy link

It's a great
Thank you very much 🌹🌹🌹

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

No branches or pull requests

5 participants