pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
14.96k stars 3.55k forks source link

WhatsApp does not work on v2.3XXX #2789

Closed Eonus closed 1 month ago

Eonus commented 6 months ago

Is there an existing issue for this?

Describe the bug

Three days ago I started to receive the following error on account start: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'push')\n at fillModuleArray (eval at <anonymous> (:2:5), <anonymous>:6:74)\n at moduleRaid (eval at <anonymous> (:2:5), <anonymous>:15:3)\n at puppeteer_evaluation_script:4:17

Expected behavior

As a user, I expect to be logged in and able to send messages. But I am seeing desribed error.

Steps to Reproduce the Bug or Issue

  1. Run basic example
  2. On some accounts it is not logged in

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Linux and Windows whatsapp-web.js version: latest, installed directly from GitHub (https://github.com/pedroslopez/whatsapp-web.js/commit/ef2f725bce1bd1afd8491f9de0cd2ed06a6febc3) WhatsApp Web version: 2.3000.1011643235 Node.js version: v18.19.0

Additional context

  1. It is possible that the problem is related to new version (https://github.com/pedroslopez/whatsapp-web.js/commit/17c75ccf5f5a5103e80f8eaa08e641f065de4fea new 2.2408.1 wweb version)
  2. I found where error is thrown, it is inside moduleraid library (Related issue - https://github.com/pedroslopez/moduleRaid/issues/5)
  3. Other related issues - https://github.com/pedroslopez/whatsapp-web.js/issues/2785
albanirneves commented 4 months ago

same here

unhandledRejection signal received. 
 TypeError: Cannot read properties of null (reading '1')
 TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
maurotlxd commented 4 months ago

same here

unhandledRejection signal received. 
 TypeError: Cannot read properties of null (reading '1')
 TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

the solution is here , it works for me

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});
rodrigooliveira87 commented 4 months ago

same here

unhandledRejection signal received. 
 TypeError: Cannot read properties of null (reading '1')
 TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

the solution is here , it works for me

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

even when you restart?

MiguelArgentina commented 4 months ago

const client = new Client({

I see, but in our case, we are using RemoteAuth, and this would hardcode the same version (2.2407.3) for every client that creates a whatsapp session, am I correct? EDIT: fix typo

maurotlxd commented 4 months ago

same here

unhandledRejection signal received. 
 TypeError: Cannot read properties of null (reading '1')
 TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

the solution is here , it works for me

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

even when you restart?

Yes, it works for me after restart

ccontato commented 4 months ago

same here

unhandledRejection signal received. 
 TypeError: Cannot read properties of null (reading '1')
 TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

the solution is here , it works for me

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

even when you restart?

Where did you put this code? In Client.js file?

albanirneves commented 4 months ago

Yes, it works, but what can we do when this wwebVersion of wppconnect get outdated?

maurotlxd commented 4 months ago

same here

unhandledRejection signal received. 
 TypeError: Cannot read properties of null (reading '1')
 TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

the solution is here , it works for me

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

even when you restart?

Where did you put this code? In Client.js file?

I put that code in my main js file , where i create the conexion to whatsappweb.js

MiguelArgentina commented 4 months ago

@maurotlxd, would you happen to know what can I do when using RemoteAuth? This works for one session

seb5433 commented 4 months ago

same here

unhandledRejection signal received. 
 TypeError: Cannot read properties of null (reading '1')
 TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

the solution is here , it works for me

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

even when you restart?

Where did you put this code? In Client.js file?

I put that code in my main js file , where i create the conexion to whatsappweb.js

For those unfamiliar with the source of LocalAuth, it can be imported from whatsapp-web-js

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

DonVoid18 commented 4 months ago

También el mismo problema.

pepev94 commented 4 months ago

También el mismo problema.

A mi me funciono las soluciones de

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

Lo unico es que tuve que borrar las sessiones ya existentes y hacer login con QR desde el principio

brunox64 commented 4 months ago

the project moduleRaid was updated, however still necessary to update file src/util/Intected.js

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

console.warn('COMET package version:%s', window.Debug?.VERSION)

eval('var moduleRaid = ' + moduleRaidStr);
// eslint-disable-next-line no-undef
window.mR = moduleRaid();
//window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
window.Store = {};

if (isComet) {
    window.Store.Chat = window.mR.findModule('Chat')[1].Chat;
} else {
    window.Store.Chat = window.mR.findModule(m => m.default && m.default.Chat)[0].default.Chat;
}

window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
window.Store.BlockContact = window.mR.findModule('blockContact')[0];

if (isComet) {
    window.Store.Call = window.mR.findModule('Call')[0].Call;
} else {
    window.Store.Call = window.mR.findModule((module) => module.default && module.default.Call)[0].default.Call;
}

window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;

if (isComet) {
    window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].GroupMetadata;
} else {
    window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
}

if (isComet) {
    window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
} else {
    window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
}

if (isComet) {
    window.Store.Contact = window.mR.findModule('Contact')[0].Contact;
}

window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
window.Store.ContactCollection = window.mR.findModule('ContactCollection')[0].ContactCollection;
window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0];
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];

if (isComet) {
    window.Store.MsgKey = window.mR.findModule('fromString')[0];
} else {
    window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
}

if (isComet) {
    window.Store.Msg = window.mR.findModule('Msg')[1].Msg;
}

if (isComet) {
    window.Store.OpaqueData = window.mR.findModule('createFromData')[0];
} else {
    window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
}

window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
window.Store.SendClear = window.mR.findModule('sendClear')[0];
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
window.Store.EditMessage = window.mR.findModule('addAndSendMessageEdit')[0];
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
window.Store.ContactMethods = window.mR.findModule('getUserid')[0];
window.Store.BusinessProfileCollection = window.mR.findModule('BusinessProfileCollection')[0].BusinessProfileCollection;

if (isComet) {
    window.Store.UploadUtils = window.mR.findModule('encryptAndUpload')[0].encryptAndUpload;
} else {
    window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
}

if (isComet) {
    try {
        window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
    } catch (e) {
        try {
            window.Store.UserConstructor = window.mR.findModule('isServer')[0].isServer;
        } catch (e2) {
            try {
                window.Store.UserConstructor = window.mR.findModule('isUser')[0].isUser;
            } catch (e3) {
                let checkType = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser))[0].default
                if (checkType.isServer) {
                    window.Store.UserConstructor = checkType.isServer
                } else if (checkType.isUser) {
                    window.Store.UserConstructor = checkType.isUser
                }
            }
        }
    }
} else {
    window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
}

window.Store.Validators = window.mR.findModule('findLinks')[0];
rodrigooliveira87 commented 4 months ago

the project moduleRaid was updated, however still necessary to update file src/util/Intected.js

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

console.warn('COMET package version:%s', window.Debug?.VERSION)

eval('var moduleRaid = ' + moduleRaidStr);
// eslint-disable-next-line no-undef
window.mR = moduleRaid();
//window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
window.Store = {};

if (isComet) {
    window.Store.Chat = window.mR.findModule('Chat')[1].Chat;
} else {
    window.Store.Chat = window.mR.findModule(m => m.default && m.default.Chat)[0].default.Chat;
}

window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
window.Store.BlockContact = window.mR.findModule('blockContact')[0];

if (isComet) {
    window.Store.Call = window.mR.findModule('Call')[0].Call;
} else {
    window.Store.Call = window.mR.findModule((module) => module.default && module.default.Call)[0].default.Call;
}

window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;

if (isComet) {
    window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].GroupMetadata;
} else {
    window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
}

if (isComet) {
    window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
} else {
    window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
}

if (isComet) {
    window.Store.Contact = window.mR.findModule('Contact')[0].Contact;
}

window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
window.Store.ContactCollection = window.mR.findModule('ContactCollection')[0].ContactCollection;
window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0];
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];

if (isComet) {
    window.Store.MsgKey = window.mR.findModule('fromString')[0];
} else {
    window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
}

if (isComet) {
    window.Store.Msg = window.mR.findModule('Msg')[1].Msg;
}

if (isComet) {
    window.Store.OpaqueData = window.mR.findModule('createFromData')[0];
} else {
    window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
}

window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
window.Store.SendClear = window.mR.findModule('sendClear')[0];
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
window.Store.EditMessage = window.mR.findModule('addAndSendMessageEdit')[0];
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
window.Store.ContactMethods = window.mR.findModule('getUserid')[0];
window.Store.BusinessProfileCollection = window.mR.findModule('BusinessProfileCollection')[0].BusinessProfileCollection;

if (isComet) {
    window.Store.UploadUtils = window.mR.findModule('encryptAndUpload')[0].encryptAndUpload;
} else {
    window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
}

if (isComet) {
    try {
        window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
    } catch (e) {
        try {
            window.Store.UserConstructor = window.mR.findModule('isServer')[0].isServer;
        } catch (e2) {
            try {
                window.Store.UserConstructor = window.mR.findModule('isUser')[0].isUser;
            } catch (e3) {
                let checkType = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser))[0].default
                if (checkType.isServer) {
                    window.Store.UserConstructor = checkType.isServer
                } else if (checkType.isUser) {
                    window.Store.UserConstructor = checkType.isUser
                }
            }
        }
    }
} else {
    window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
}

window.Store.Validators = window.mR.findModule('findLinks')[0];

Can you explain a little more? Using this file version we can use on 2.3x?

JavierVargasIPN2018 commented 4 months ago

También el mismo problema.

A mi me funciono las soluciones de

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

Lo unico es que tuve que borrar las sessiones ya existentes y hacer login con QR desde el principio

Lo mismo,a mi también me funcionó esto,solo borre las sesiones

rodrigooliveira87 commented 4 months ago

webpack-exodus branch Just release a fix

MoudiZd commented 4 months ago

If anyone encounter error while trying to send media using new release

Just change this line

const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash);

Into this

const mediaObject = window.Store.MediaObject(mediaData.filehash);

In src/util/Utils.js on line 323, and give a try

Another approach and to keep legacy compatibility, is to change the line which export mediaobject in src/util/Injected/store.js

from window.Store.MediaObject = require('WAWebMediaStorage').getOrCreateMediaObject;

To

window.Store.MediaObject = require('WAWebMediaStorage');

In this way we do not need to change the Utils.js file because is common between legacy and version, and we just change store exposing for new one where the real issue occurs

rodrigooliveira87 commented 4 months ago

If anyone encounter error while trying to send media using new release

Just change this line

const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash);

Into this

const mediaObject = window.Store.MediaObject(mediaData.filehash);

In src/util/Utils.js on line 323, and give a try

wouldn't it be in Injected.js file?

MoudiZd commented 4 months ago

If anyone encounter error while trying to send media using new release Just change this line const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash); Into this const mediaObject = window.Store.MediaObject(mediaData.filehash); In src/util/Utils.js on line 323, and give a try

wouldn't it be in Injected.js file?

In new release there is no injected.js but instead there is store.js, check src/util folder

rodrigooliveira87 commented 4 months ago

If anyone encounter error while trying to send media using new release Just change this line const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash); Into this const mediaObject = window.Store.MediaObject(mediaData.filehash); In src/util/Utils.js on line 323, and give a try

wouldn't it be in Injected.js file?

In new release there is no injected.js but instead there is store.js, check src/util folder

I found it, but in Injected subpath, It's working, thx

felipemonteiro44 commented 4 months ago

This worked for me

let modObj = {};
        if (parseFloat(window.Debug.VERSION) < 2.3) {
            (window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([["parasiteijn34h82hdf"], {},
            function (findMod) {
                // Percorrendo os módulos encontrados e adicionando-os ao objeto modObj
                Object.keys(findMod.m).forEach(function (mod) { modObj[mod] = findMod(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) {
                    modObj[mod] = {
                        default: modulos.defaultExport,
                        factory: modulos.factory,
                        ...modulos
                    };
                    if (Object.keys(modObj[mod].default).length == 0) {
                        try {
                            self.ErrorGuard.skipGuardGlobal(true);
                            Object.assign(modObj[mod], self.importNamespace(mod));
                        } catch (e) {
                        }
                    }
                }
            })
        }

        register(modObj);
rohankm commented 4 months ago

This worked for me

let modObj = {};
        if (parseFloat(window.Debug.VERSION) < 2.3) {
            (window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([["parasiteijn34h82hdf"], {},
            function (findMod) {
                // Percorrendo os módulos encontrados e adicionando-os ao objeto modObj
                Object.keys(findMod.m).forEach(function (mod) { modObj[mod] = findMod(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) {
                    modObj[mod] = {
                        default: modulos.defaultExport,
                        factory: modulos.factory,
                        ...modulos
                    };
                    if (Object.keys(modObj[mod].default).length == 0) {
                        try {
                            self.ErrorGuard.skipGuardGlobal(true);
                            Object.assign(modObj[mod], self.importNamespace(mod));
                        } catch (e) {
                        }
                    }
                }
            })
        }

        register(modObj);

where to modify this code?

timesrunaway commented 4 months ago

webpack-exodus branch Just release a fix

this work for me!

sgnm-ozkanaydin commented 4 months ago

webpack-exodus branch Just release a fix

this work for me!

how do we do this

timesrunaway commented 4 months ago

webpack-exodus branch Just release a fix

this work for me!

how do we do this

Depends on where you use it, I would just replace the implementation of window.Store

aidar87 commented 4 months ago

I got related error Cannot read properties of null (reading '1'), setting webVersionCache helped me too

BernetteGunasekaran commented 4 months ago

Hi, Which file I need to modify to get it working?

cantdocpp commented 4 months ago

Anyone know how to use the new PR update ?

devaec commented 4 months ago

Hello everyone ı found solve...

Works it mee . please try

File location : node_modules/@pedroslopez/moduleraid bla bla , only one file have...

Then only " fillModuleArray function area change..

This is code ;

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();
ThirtySix361 commented 4 months ago

the project moduleRaid was updated, however still necessary to update file src/util/Intected.js

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

console.warn('COMET package version:%s', window.Debug?.VERSION)

eval('var moduleRaid = ' + moduleRaidStr);
// eslint-disable-next-line no-undef
window.mR = moduleRaid();
//window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
window.Store = {};

if (isComet) {
    window.Store.Chat = window.mR.findModule('Chat')[1].Chat;
} else {
    window.Store.Chat = window.mR.findModule(m => m.default && m.default.Chat)[0].default.Chat;
}

window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
window.Store.BlockContact = window.mR.findModule('blockContact')[0];

if (isComet) {
    window.Store.Call = window.mR.findModule('Call')[0].Call;
} else {
    window.Store.Call = window.mR.findModule((module) => module.default && module.default.Call)[0].default.Call;
}

window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;

if (isComet) {
    window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].GroupMetadata;
} else {
    window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
}

if (isComet) {
    window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
} else {
    window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
}

if (isComet) {
    window.Store.Contact = window.mR.findModule('Contact')[0].Contact;
}

window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
window.Store.ContactCollection = window.mR.findModule('ContactCollection')[0].ContactCollection;
window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0];
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];

if (isComet) {
    window.Store.MsgKey = window.mR.findModule('fromString')[0];
} else {
    window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
}

if (isComet) {
    window.Store.Msg = window.mR.findModule('Msg')[1].Msg;
}

if (isComet) {
    window.Store.OpaqueData = window.mR.findModule('createFromData')[0];
} else {
    window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
}

window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
window.Store.SendClear = window.mR.findModule('sendClear')[0];
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
window.Store.EditMessage = window.mR.findModule('addAndSendMessageEdit')[0];
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
window.Store.ContactMethods = window.mR.findModule('getUserid')[0];
window.Store.BusinessProfileCollection = window.mR.findModule('BusinessProfileCollection')[0].BusinessProfileCollection;

if (isComet) {
    window.Store.UploadUtils = window.mR.findModule('encryptAndUpload')[0].encryptAndUpload;
} else {
    window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
}

if (isComet) {
    try {
        window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
    } catch (e) {
        try {
            window.Store.UserConstructor = window.mR.findModule('isServer')[0].isServer;
        } catch (e2) {
            try {
                window.Store.UserConstructor = window.mR.findModule('isUser')[0].isUser;
            } catch (e3) {
                let checkType = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser))[0].default
                if (checkType.isServer) {
                    window.Store.UserConstructor = checkType.isServer
                } else if (checkType.isUser) {
                    window.Store.UserConstructor = checkType.isUser
                }
            }
        }
    }
} else {
    window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
}

window.Store.Validators = window.mR.findModule('findLinks')[0];

Uncaught ReferenceError: moduleRaidStr is not defined

pedrodamiani21 commented 4 months ago

Funcionou pra mim fazendo: Alterando em: webCache/LocalWebCache.js a linha 34; De: const version = indexHtml.match(/manifest-([\d\.]+).json/)[1]; Para: const version = indexHtml.match(/manifest.json/)[1]; Depois fui em moduleRaid na lib node_modules/@pedroslopez/moduleraid e fiz a modificação do Devaec

wmazuchi commented 4 months ago

Funcionou pra mim fazendo: Alterando em: webCache/LocalWebCache.js a linha 34; De: const version = indexHtml.match(/manifest-([\d.]+).json/)[1]; Para: const version = indexHtml.match(/manifest.json/)[1]; Depois fui em moduleRaid na lib node_modules/@pedroslopez/moduleraid e fiz a modificação do Devaec

Testei a sua solução e a conexão é feita, mas outros erros começaram a aparecer.

Quando envio a mensagem para o Whatsapp: ERROR: Error handling whatsapp message: Err: [object Object] Ou quando tento enviar uma mensagem: Err: Error: Protocol error (Runtime.callFunctionOn): Session closed.

brunox64 commented 4 months ago

o código que postei é somente um trecho no arquivo src/util/Injected.js, a solução completa depende de utilizar um pacote com a última correção da dependência moduleRaid que ainda não estava disponível no npm, somente no repositório, e então alterar o Injected.js

  1. empacotar correção do repositório @pedroslopez/moduleRaid
  2. empacotar whatsapp-web.js com a alteração no Intected.js e o pacote atualizado do moduleRaid
NissiusRibas commented 4 months ago

This worked for me

let modObj = {};
        if (parseFloat(window.Debug.VERSION) < 2.3) {
            (window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([["parasiteijn34h82hdf"], {},
            function (findMod) {
                // Percorrendo os módulos encontrados e adicionando-os ao objeto modObj
                Object.keys(findMod.m).forEach(function (mod) { modObj[mod] = findMod(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) {
                    modObj[mod] = {
                        default: modulos.defaultExport,
                        factory: modulos.factory,
                        ...modulos
                    };
                    if (Object.keys(modObj[mod].default).length == 0) {
                        try {
                            self.ErrorGuard.skipGuardGlobal(true);
                            Object.assign(modObj[mod], self.importNamespace(mod));
                        } catch (e) {
                        }
                    }
                }
            })
        }

        register(modObj);

qual arquivo?

eduhpicolo commented 4 months ago

for me this doesnt work anymore.. uma bagunca ja estao os comits e versoes =( mesmo seguindo a documentacao tens q fazer varias outras funcoes pra funcionar, e depois de um temp ja deixa de funcionar outra vez :...(

rodrigofsantos commented 4 months ago

Funcionou pra mim fazendo: Alterando em: webCache/LocalWebCache.js a linha 34; De: const version = indexHtml.match(/manifest-([\d.]+).json/)[1]; Para: const version = indexHtml.match(/manifest.json/)[1]; Depois fui em moduleRaid na lib node_modules/@pedroslopez/moduleraid e fiz a modificação do Devaec

Aqui pra min não funcionou e agora esta apresentando este erro :

ERROR: Error handling whatsapp message: Err: Error: Evaluation failed: Error: Data passed to getter must include an id property (it's how we memoize) but got undefined 0|whaticket-backend | at new Error (:5:31) 0|whaticket-backend | at h (https://static.whatsapp.net/rsrc.php/v3/yL/r/9UCuQM9lH2s.js?_nc_x=Ij3Wp8lg5Kz:70:191) 0|whaticket-backend | at t (https://static.whatsapp.net/rsrc.php/v3iIl84/yE/l/makehaste_jhash/ffOjKHE8RWU.js?_nc_x=Ij3Wp8lg5Kz:307:4493) 0|whaticket-backend | at Object.d [as getLinkPreview] (https://static.whatsapp.net/rsrc.php/v3iIl84/yE/l/makehaste_jhash/ffOjKHE8RWU.js?_nc_x=Ij3Wp8lg5Kz:307:2447) 0|whaticket-backend | at Object.window.WWebJS.sendMessage (puppeteer_evaluation_script:135:62) 0|whaticket-backend | at async puppeteer_evaluation_script:10:25

Alguem consegue me ajudar ?

juliomario11 commented 4 months ago

This worked for me

let modObj = {};
        if (parseFloat(window.Debug.VERSION) < 2.3) {
            (window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([["parasiteijn34h82hdf"], {},
            function (findMod) {
                // Percorrendo os módulos encontrados e adicionando-os ao objeto modObj
                Object.keys(findMod.m).forEach(function (mod) { modObj[mod] = findMod(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) {
                    modObj[mod] = {
                        default: modulos.defaultExport,
                        factory: modulos.factory,
                        ...modulos
                    };
                    if (Object.keys(modObj[mod].default).length == 0) {
                        try {
                            self.ErrorGuard.skipGuardGlobal(true);
                            Object.assign(modObj[mod], self.importNamespace(mod));
                        } catch (e) {
                        }
                    }
                }
            })
        }

        register(modObj);

let modObj = {};

This worked for me

eduhpicolo commented 4 months ago

Creo q os PR poderiam planificar um fix para o main, pq fazer o clone e depois ter que modificar os modulos nao eh legal 🫠

eduhpicolo commented 4 months ago

Please, havia comentado de uma mudança q whatsapp havia comentado 🫣 ehbum package maravilhoso e merece nao ser descontinuado 😇

lecosta27 commented 4 months ago

Isso funcionou para mim

let modObj = {};
        if (parseFloat(window.Debug.VERSION) < 2.3) {
            (window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([["parasiteijn34h82hdf"], {},
            function (findMod) {
                // Percorrendo os módulos encontrados e adicionando-os ao objeto modObj
                Object.keys(findMod.m).forEach(function (mod) { modObj[mod] = findMod(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) {
                    modObj[mod] = {
                        default: modulos.defaultExport,
                        factory: modulos.factory,
                        ...modulos
                    };
                    if (Object.keys(modObj[mod].default).length == 0) {
                        try {
                            self.ErrorGuard.skipGuardGlobal(true);
                            Object.assign(modObj[mod], self.importNamespace(mod));
                        } catch (e) {
                        }
                    }
                }
            })
        }

        register(modObj);

deixe modObj = {};

Isso funcionou para mim

E qual seria o caminho para esse arquivo?

juliomario11 commented 4 months ago

Isso funcionou para mim

let modObj = {};
        if (parseFloat(window.Debug.VERSION) < 2.3) {
            (window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([["parasiteijn34h82hdf"], {},
            function (findMod) {
                // Percorrendo os módulos encontrados e adicionando-os ao objeto modObj
                Object.keys(findMod.m).forEach(function (mod) { modObj[mod] = findMod(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) {
                    modObj[mod] = {
                        default: modulos.defaultExport,
                        factory: modulos.factory,
                        ...modulos
                    };
                    if (Object.keys(modObj[mod].default).length == 0) {
                        try {
                            self.ErrorGuard.skipGuardGlobal(true);
                            Object.assign(modObj[mod], self.importNamespace(mod));
                        } catch (e) {
                        }
                    }
                }
            })
        }

        register(modObj);

deixe modObj = {};

Isso funcionou para mim

E qual seria o caminho para esse arquivo?

image

jeffersonmiranda0 commented 4 months ago

for me this worked

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});
wmazuchi commented 4 months ago

What worked for me:

Get the moduleraid.js file from this link https://github.com/wwebjs/moduleRaid

And apply the changes from https://github.com/pedroslopez/whatsapp-web.js/issues/2789#issuecomment-2034553600 and https://github.com/pedroslopez/whatsapp-web.js/issues/2789#issuecomment-2034333596 comments.

It's working perfectly.

albanirneves commented 4 months ago

could anyone make a PR with the solution?

brunox64 commented 4 months ago

Código completo aqui nesta PR abaixo, mas precisa de compilar o moduleRaid e instalar pelo .tgz dele. PR 2882

codigoinerte commented 4 months ago
const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

Relevant wweb versions can be found here

this worked for me

yogiigabe commented 4 months ago

Isso funcionou para mim

let modObj = {};
        if (parseFloat(window.Debug.VERSION) < 2.3) {
            (window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([["parasiteijn34h82hdf"], {},
            function (findMod) {
                // Percorrendo os módulos encontrados e adicionando-os ao objeto modObj
                Object.keys(findMod.m).forEach(function (mod) { modObj[mod] = findMod(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) {
                    modObj[mod] = {
                        default: modulos.defaultExport,
                        factory: modulos.factory,
                        ...modulos
                    };
                    if (Object.keys(modObj[mod].default).length == 0) {
                        try {
                            self.ErrorGuard.skipGuardGlobal(true);
                            Object.assign(modObj[mod], self.importNamespace(mod));
                        } catch (e) {
                        }
                    }
                }
            })
        }

        register(modObj);

deixe modObj = {};

Isso funcionou para mim

E qual seria o caminho para esse arquivo?

image

Funcionou pra mim fazendo: Alterando em: webCache/LocalWebCache.js a linha 34; De: const version = indexHtml.match(/manifest-([\d.]+).json/)[1]; Para: const version = indexHtml.match(/manifest.json/)[1]; Depois fui em moduleRaid na lib node_modules/@pedroslopez/moduleraid e fiz a modificação do Devaec

I found new bugs

D:\whatsapp-api\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:528 const timeoutError = new Errors_js_1.TimeoutError(waiting for ${options.title} failed: timeout ${options.timeout}ms exceeded); ^

TimeoutError: waiting for function failed: timeout 30000ms exceeded at new WaitTask (D:\whatsapp-api\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:528:34) at DOMWorld.waitForFunction (D:\whatsapp-api\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:479:26) at Frame.waitForFunction (D:\whatsapp-api\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:1010:32) at Page.waitForFunction (D:\whatsapp-api\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:2490:33) at Client.initialize (D:\whatsapp-api\node_modules\whatsapp-web.js\src\Client.js:333:20) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v21.7.1

5h1ro commented 4 months ago

i got this error after scan qr code

my client config using

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

Screenshot from 2024-04-04 15-27-21

koral99digital commented 4 months ago

hi guys dont waste time, this is the solution that worked for me: https://github.com/pedroslopez/whatsapp-web.js/pull/2816

albanirneves commented 4 months ago

hi guys dont waste time, this is the solution that worked for me: #2816

But how can i implement it? It's already in the npm latest version?